Files
compiler-explorer/docs/internal/FrontendTesting.md
Matt Godbolt 23fad10939 Unit testing the frontend (#7829)
This adds some unit tests for the front end.

- configures "frontend tests" as a unit tests in `static/tests`,
removing the old cypress-requiring "unit" tests
- hack enough of a DOM  to get things working
- port motd and id tests
- *adds* a golden layout checks  (see #7807)
- Updates READMEs etc

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-19 08:46:57 -05:00

713 B

Frontend testing

We have a mixture of unit tests (located in static/tests) and Cypress UI tests(located in cypress/e2e).

If possible, create unit tests in static/tests for the code you are working on. If you can get away with simple state tests and don't need to do any real DOM manipulation, this is the way to go. Testing "does this filter correctly" or "do we parse this right" are perfect examples of this. These tests use happy-dom for extremely minimal DOM mocking just enough to get the code running at all.

If you need to check actual behaviour or rely on the pug loading/HTML rendering, you should use the Cypress tests.

To run the cypress tests, see this document.