reactjsvisual-studio-codejestjsvscode-jest

Jest vscode-jest Extension Running All Tests (Despite Proper Configuration and Using Git)


As the title says, I'm using Git as source control for my project, and I'm using the below configuration:

  "jest.autoRun": "watch",
  "jest.debugCodeLens.showWhenTestStateIn": ["pass", "skip", "fail", "unknown"],
  "jest.coverageFormatter": "DefaultFormatter",
  "jest.coverageColors": {
    "covered": "rgba(9, 156, 65, 0.9)",
    "uncovered": "rgba(121, 31, 10, 0.3)",
    "partially-covered": "rgba(235, 198, 52, 0.1)"

but no matter what, any change in any file triggers all tests to run, not just the affected tests. I've also tried "jest.autoRun": "on-save" and it also triggers all tests to run, not just the ones for the saved file, whether I've got code-coverage enabled or disabled.


Solution

  • Try to specify/play the single parameters. This should be the configuration you are searching for. But it is the equivalent of "on-save", so it might not work.

    "jest.autoRun": {
       "watch": false,
       "onSave": "test-src-file",
    }
    

    For further information check: https://github.com/jest-community/vscode-jest#autorun