Run jest snapshot tests locally and in CI
What does this MR do and why?
This MR allows us find the snapshot tests run them via yarn jest:snapshots
.
Context: we do not have any definite folder structure for snapshot tests, so we cannot simply provide one glob
pattern to jest config - instead, we introduce a new jest.config.snapshots.js
with a function that scans through all of the jest specs, identifying the files containing the phrases toMatchSnapshot
or toMatchInlineSnapshot
, and only run them.
We are also adding 2 manual jobs in CI running snapshot tests, which are allowed to fail right now.
Update: changed this to 1 manual job to only run vue3 snapshot tests. vue2 snapshot tests already run as a part of the jest jobs so we don't need to duplicate.
Screenshots or screen recordings
With this change, MR pipelines will start seeing the following manual job and is allowed to fail:
How to set up and validate locally
We can verify the scripts locally with the following command:
verify that the snapshot tests can run successfully:
yarn jest:snapshots
Check that these commands will first compile the snapshot config and successfully run all snapshot tests.
To run everything in vue-3-compat
:
VUE_VERSION=3 yarn jest:snapshots
Check that jest tests run but some tests fail.
Check this MR's latest pipeline for verification of the CI config:
- jest-snapshot-vue3: https://gitlab.com/gitlab-org/gitlab/-/jobs/5376883595
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.