Introduce testing library with cypress#1284
Merged
Merged
Conversation
zetter-rpf
temporarily deployed
to
previews/1284/merge
January 9, 2026 17:12 — with
GitHub Actions
Inactive
zetter-rpf
force-pushed
the
introduce-testing-library-with-cypress
branch
from
January 12, 2026 09:30
6c60bd2 to
5002a96
Compare
zetter-rpf
temporarily deployed
to
previews/1284/merge
January 12, 2026 09:30 — with
GitHub Actions
Inactive
Contributor
Author
|
Note that this is failing because of #1285 |
Contributor
|
Yes I like this approach, it's more in line with our unit tests, which is more intuitive...using copilot to migrate them makes sense, and will ensure we have a new baseline to work from. it might be an idea to share this approach in a knowledge sharing session too, so everybody is onboard. |
We're already using @testing-library for our react code, the library for cypress brings the same benefits - it will allow us to write end to end tests that better mimic user behaviour by interacting with elements based on their role/text/labels rather than their classes. As well as making the specs easier to follow and de-coupled from our class names, it helps to ensure our site is accessible (i.e form elements have labels). To demonstrate this I've written added a new test to work with multiple files. If we like this approach, we can change over other specs as we write or update them. Note that cypress testing library doesn't seem to have direct support for the Shadow DOM yet (see testing-library/dom-testing-library#413 ) but we still works if we load the shadow DOM using the cypress finder. One quirk I found is that `findByLabelText` doesn't work from the root shadow dom element which is why I've called it on `children()`.
cypress aliases let you share values between setup and files. See [1] [1] https://docs.cypress.io/app/core-concepts/variables-and-aliases
zetter-rpf
force-pushed
the
introduce-testing-library-with-cypress
branch
from
January 12, 2026 11:35
5002a96 to
84f6ec8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/878
We're already using https://github.com/testing-library for our react unit tests code, the library for cypress brings the same benefits. It will allow us to write end to end tests that better mimic user behaviour by interacting with elements based on their role/text/labels rather than their classes. As well as making the specs easier to follow and de-coupled from our class names, it helps to ensure our site is accessible (e.g. form elements have labels).
To demonstrate this I've written added a new test to work with multiple files. If we like this approach, we can change over other specs as we write or update them.
Note that cypress testing library doesn't seem to have direct support for the Shadow DOM yet (see testing-library/dom-testing-library#413 ) but we still works if we load the shadow DOM using the cypress finder. One quirk I found is that
findByLabelTextdoesn't work from the root shadow DOM element which is why I've called it onchildren().This branch is based off of
update-cypress. If we're happy I will merge to main after that branch.Feedback wanted: