Running frontend tests#

Once you’ve made some changes to the codebase, it is important to run tests. Openverse uses unit tests, Playwright tests for end-to-end, and visual regression testing of the app and Storybook components. This guide will help you run the tests. To learn more about how to test PRs, read the testing guidelines. To learn more about the Playwright tests, read this guide. To learn more about the Storybook visual regression tests, read this guide.

Steps#

  1. Ensure you’ve gone through the quickstart guide.

  2. Run unit tests for the frontend.

    $ just frontend/run test:unit
    

    Note

    Unit tests are automatically run by pre-commit before Git push, if you’ve set up pre-commit’s Git hooks by running the following command.

    $ just precommit
    
  3. Run the Playwright tests. This will run both the end-to-end tests and the app visual regression tests.

    $ just frontend/run test:playwright
    
  4. Run the Storybook visual regression tests.

    $ just frontend/run test:storybook
    

Updating snapshots#

If you’ve made changes to the frontend that require updating snapshots, you can run the playwright tests with the -u flag. For example, this will update the snapshots for the app visual regression tests:

$ just frontend/run test:playwright visual-regression -u