Skip to content

Testing approach #76

@matthew-shaw

Description

@matthew-shaw
          Hi @matthew-shaw I work at Crown Commercial Service and look after the Digital Marketplace (which used to be managed by GDS).

We have a frontend repo for Digital Marketplace components (like GOV.UK Frontend) which contains Nunjucks components and the Flask apps would do some magic (as far as I'm concerned) to allow Jinja to parse the Nunjucks templates. Because this is not going to be maintainable long term I've created a project, inspired by this project, Digital Marketplace Jinja Templates which contains Jinja Templates.

Now I originally looked at forking govuk-frontend-diff and doing something similar for Digital Marketplace but I saw in the README that the GOV.UK Frontend package now includes fixtures (i.e. the expected HTML for the component with different params). So for the next release of Digital Marketplace Frontend, because it was not already, I made it generated fixtures with the HTML for all the components.

I've created an app which responds to requests to generate the components. Within the test it gets all of the fixtures from the node module and generates a set of pytest fixtures to test. It then sends the request to the app and then compares the response.

Now, because there can be difference in how things are rendered (i.e. the indent is slightly different or Nunjucks having true where as Jinja will have True) I have added a method html_to_one_line which "normalises" the results so they can be compared.

This not a perfect solution by any means and may not be what you want with this project but I thought it might be useful to share considering you seem to be at a bit of bottleneck with how you're going to test from v5 onward.

Originally posted by @tim-s-ccs in #70 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions