JESTでテストを書いていて全てのテストが通るようになったのだが、最後npm run jest
のexit statusが1
で終了してしまう
Snapshot Summary › 1 snapshot file obsolete from 1 test suite. To remove it, run `npm run jest -- -u`. Test Suites: 23 passed, 23 total Tests: 50 passed, 50 total Snapshots: 1 file obsolete, 0 total Time: 10.776s Ran all test suites. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! my-app@0.0.0 jest: `jest` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the my-app@0.0.0 jest script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /Users/ugaboxxx/.npm/_logs/2020-07-22T03_09_44_486Z-debug.log
同様のIssueが上がっていて、まだOPENしているため未解決な事象かなと思ったのだが
上のコメントの中にobsolete
というのが原因なので消せばエラーが消えるというのがあったので
Snapshots: 3 obsolete, 26 passed, 26 total
obsolete - are the cause of the error, after their removal, the error is gone.
以下のコマンドで消してみたところエラーが解消された
$ npm run jest -- -u
-u
はスナップショットテスト実行中に失敗した全てのスナップショットを再取得する場合に指定するオプション
覚えはないが過去にやったスナップショットテストの残りが悪さをしていたみたい