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:
I have already implemented the govuk-frontend tests against a custom render function in https://github.com/penx/govuk-frontend-react - but I had to manually copy code across from govuk-frontend rather than import it.
To stress test this proposal I would recommend trying out these components:
I'm making progress with this by manually copying tests across but thought it worth noting that I've found that using snapshot tests e.g. on input is a bit heavy handed. If we wanted the tests to be usable for testing a port then we probably don't want 100% markup alignment - perhaps snapshot tests are best avoided?
For now I've written a script that extracts the template tests and examples yaml from govuk-frontend and publishes them to npm as govuk-frontend-template-spec, in a way that can be used by a port:
Thanks for this @penx 🙌. We think this work is worth doing as part of a future mission into supporting other templating languages. We've added it to our roadmap board here.
hi, any update on this? Is this something that could be looked at soon?
Rolling this issue up into a slightly broader epic: https://github.com/alphagov/govuk-frontend/issues/1830
Thanks @penx for your input – it'll be really helpful when we pick this up.
Most helpful comment
Thanks for this @penx 🙌. We think this work is worth doing as part of a future mission into supporting other templating languages. We've added it to our roadmap board here.