-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add visual regression testing with cypress #1339
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I think it basically works now. This is the screentshot cypress produces on my system for a simple AppSidebar: Things to do:
|
Awesome work @raimund-schluessler 🤗 |
249dac7
to
b333704
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please add
cypress/videos
to gitignore :) - Maybe also play with the background instead of the header?
- Shall we add a default SdidebarContent?
- If not maybe we can only capture the header?
- Add Cypress action
Looks like we have to run cypress in a Docker container as the images produced by the Github action differ from the ones on my machine. @skjnldsv Do you have an idea how to do that? |
02dc3c5
to
13234dd
Compare
DOne, sorry! :) |
Hm, no idea. I get the same error no matter what. |
13234dd
to
3860779
Compare
Fixed @raimund-schluessler |
Nice, it runs through on my machine now. But the screenshots taken are different from the previous ones. I will try to update them and push them here. Let's see. |
The screenshots seems to actually be the same :)
|
That's what I meant with "different". The letters are rendered slightly different than before. |
It seems it's not uploading the diff files though cypress-io/github-action@22681e3 EDIT: doesn't upload to cypress but to github 😕 EDIT2: nope! 😢 |
We could also use https://github.com/meinaart/cypress-plugin-snapshots |
I don't mind. Both https://github.com/mjhea0/cypress-visual-regression and https://github.com/meinaart/cypress-plugin-snapshots seem to be fine. The question is how to handle the small differences in the screenshots. Whether we can prevent the different rendering or increase the threshold. |
@skjnldsv I think it uploaded correctly: https://dashboard.cypress.io/projects/3paxvy/runs/8/test-results/408ee0df-0b7a-41b3-b473-433ba35020af How we treat slightly different screenshots is still up to debate. |
It's missing the superposée red diffs images :) |
a46be18
to
1e7d85e
Compare
@skjnldsv I moved the cypress runner into a docker container 1e7d85e. This ensures that the local results and the results in CI are exactly the same, since they run in the samer docker container. Now we only need to fix the uploading to cypress.io and cleanup a bit.
|
f093d49
to
1ca40a6
Compare
@skjnldsv Please have a look. I think it is in a good shape now. I would add more conditions for AppSidebar (primary-actions, long title etc.) in a follow-up PR, so we can also test if it really finds regressions. By the way: changing something on the AppSidebar CSS is correctly reported. 👍 |
Signed-off-by: Raimund Schlüßler <[email protected]>
Achieves reliable results cross-platform Signed-off-by: Raimund Schlüßler <[email protected]>
1ca40a6
to
b080eb7
Compare
- name: Cypress run | ||
env: | ||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | ||
run: npm run cypress:record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not fond, I think that complicates the setup a lot.
Why did we need to load this inside a docker container?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we need to load this inside a docker container?
Because the tests now pass, and failed before 😉
The tiny differences we saw with the font rendering are caused by running the tests on different machines. Between them, maybe the browser, the display settings, the available fonts or whatever else differs slightly, leading to tiny differences in the rendering which make the tests fail.
Of course, we could increase the difference threshold to make the tests pass. But this is not really an option as it would lead to false positives.
The difference in this image is 0.1623 and is not a regression (it's the difference between running locally on my machine and inside the docker container):
The difference in this image is 4 times lower with 0.0406 and it clearly is a regression (I intentionally changed the padding of the close button):
So, running the visual tests in the very same environment ensured by a docker container seems like the only option to fix this. If you have another idea, I am open to check it out.
I think that complicates the setup a lot.
It sure is complicated, but I got the impression, so is visual regression testing in general 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cypress actually have dockerized github actions as well.
We could have use those?
I'm just not fond of having to also maintain a Docker setup there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with using this github action docker setup, but we have to as well locally run cypress within the container. How would you do that then?
matrix: | ||
node-version: ['12.x'] | ||
|
||
name: Runner ${{ matrix.containers }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No parallelism anymore (Wasn't needed because we have 1 test, but how would we add more?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we gain much here. The whole Cypress
action runs for 4:00 min. The cypress run took 35 s, of which running the actual AppSideber.visual.js test took 10 s. We would need to add a lot of tests to really save time.
Edit: But feel free to add it again, of course.
This PR tries to add visual regression testing with cypress. I think we really need this, since some components start to be that complex, that we cannot change them without automatically testing for visual regressions. E.g. the AppSidebar component has at least 64 valid combinations of props and slots only for the header, which all change the visual appearance of the component. Testing this manually is basically impossible, since every small change needs to be tested with every valid combination of options. So visual regression testing would help a lot to resolve #1338 and prevent similar problems in the future.
However, the cypress setup does not work at the moment, I get the multiple similar errors like this:Fixed with a90e2b4Now I get
Will look into this tomorrow.
Any feedback is very welcome, since I am new to cypress. @skjnldsv I saw that you use cypress for the viewer app, maybe you have an idea what is wrong here.