Jest 스냅샷 테스트 관련 오류

2022. 8. 16. 01:38서버 프로그래밍

로컬에서는 문제없이 테스트가 실행되지만, CI/CD 파이프라인에서는 다음과 같은 오류가 발생한다.

New snapshot was not written. The update flag must be explicitly passed to write a new snapshot.
This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default.

 

To resolve this, we will need to update our snapshot artifacts. You can run Jest with a flag that will tell it to re-generate snapshots:

jest --updateSnapshot

 

https://stackoverflow.com/questions/59078246/jest-react-new-snapshot-was-not-written-the-update-flag-must-be-explicitly-pa

 

Jest React - New snapshot was not written. The update flag must be explicitly passed to write a new snapshot

I have a asp.net core project created with React template, trying to unit test a simple component with Jest snapshot and I am receiving below error.Can any one suggest how to fix it. index.js imp...

stackoverflow.com

https://jestjs.io/docs/snapshot-testing

 

Snapshot Testing · Jest

Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.

jestjs.io