Q. VSCodeが勝手にテストを走らせるようになった

いつからか VSCode 起動時やファイルを変更した際、Git 管理下にない node_modules などに変化があった場合にも、テストが起動され、Test Results が勝手に開かれるようになった。

発生時のメッセージを調べると vscode-jest に依るものであることが分かった。

GitHub - jest-community/vscode-jest: The optimal flow for Jest based testing in VS Code

on-demand を明示的に指定して、手動実行のみにした。

{
"jest.runMode": "on-demand"
}

以前はこの設定が異なったらしい。

https://stackoverflow.com/questions/57132803/completely-disable-auto-run-of-jest-test-runner-in-visual-studio-code-editor

2021 年時点

{
"jest.autoRun": "false"
}

2022 年時点

{
"jest.autoRun": { "watch": false }
}