alphagov / govuk-frontend

GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.
https://frontend.design-system.service.gov.uk/
MIT License
1.18k stars 321 forks source link

Investigate move to more modern tools for our in-browser tests #3049

Closed romaricpascal closed 1 year ago

romaricpascal commented 1 year ago

What

Puppeteer has its limitations when it comes to running our in-browser tests. We'd be looking to move away from it towards a more modern tool like Cypress or Playwright.

~Pick 1 or 2 components and try rewriting their behavioural tests using the two frameworks.~

Re-implement tests in both tool for:

Demo back to the rest of the team.

Why

We want to understand if using Cypress or Playwright (or similar) can make it easier for us to test in multiple browsers, giving us confidence to ship the upcoming changes to the way we write JavaScript.

We also think this can help us with managing session state between tests.

Assumptions

Timebox

We should review progress after this period of time has elapsed, even if the spike has not been 'completed'

2 days

Who is working on this?

Spike lead: Colin

Spike buddy: Romaric

Questions to answer

Done when

You may find it helpful to refer to our expected outcomes of spikes.

romaricpascal commented 1 year ago

As a tangential thought, we could look into how our tests are split to ensure that we rely on heavy things like browser tests and review apps only when necessary. As a strawperson split, for discussion:

  1. End to end browser tests relying on user-level interactions ("Click on button with this text", "Type in field with this label") and verifications ("The screen displays X", "The browser announced Y" if possible...) rather than lower level use of IDs and classes
  2. Technical check of IDs attributes and classes without necessarily spinning up a whole browser
  3. Unit tests to check response of individual functions/methods to ranges of input

Which tool we pick shouldn't affect such reorganisation should we chose to go for it.

This may tie more into https://github.com/alphagov/govuk-frontend/issues/2565

romaricpascal commented 1 year ago

An extra tool we may want to investigate in a separate spike would be https://webdriver.io/. Authoring and debugging experience look a bit more dev-y (no GUI to replay the tests at first glance), but the use of the WebDriver protocol would open the door to a wider range of browsers using Browserstack Automate or Saucelabs

romaricpascal commented 1 year ago

Sharing some notes and links to code:

romaricpascal commented 1 year ago

Investigation is done, newer work will be tracked by #3278.