Skip to content

Run jest snapshot tests locally and in CI

Jennifer Li requested to merge jennli-setup-vue-3-compact-pipeline into master

What does this MR do and why?

Re: Setup CI pipeline to run Jest tests in vue3 compat (gitlab-org/quality/engineering-productivity/team#305)

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:

Screenshot_2023-10-25_at_4.56.54_PM

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:

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jennifer Li

Merge request reports