Skip to content

Include unit tests in package output in a way that they can be used by ports #1095

@penx

Description

@penx

Further to a discussion I had recently with @36degrees and an initial proposal at #1089

For projects acting as a port of the nunjucks templates, in a different templating language, it would be useful to be able to run your unit tests as a 'spec' against a custom render function, to ensure the port has feature parity with the govuk-frontend nunjucks templates.

This would require:

  • component/component.yaml being copied across to package build (perhaps as json to make it easier to include from parent projects
  • unit tests to be moved in to a separate file (e.g. template.spec.js) that don't auto-execute when required, as per WIP: export tests as a 'spec' #1089, but still have template.unit.js execute them when running in govuk-frontend.
  • allow a custom render function to be passed in
    • discuss whether a custom render function should return a string or a pre-wrapped cheerio object
  • either don't use axe-helper.js in the exported spec (assume it has already been configured) or move it in to distributed package (it currently sits under /lib and is not available in the distributed/npm version)
  • move get-examples.js to a location so that it is available in the distributed/npm package

Related: jestjs/jest#7501

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions