Vscode-jest: How to run test cases of only the file currently being edited.

Created on 9 Dec 2019  路  6Comments  路  Source: jest-community/vscode-jest

Environment

  1. node -v: [fill]
  2. npm -v: [fill]
  3. npm ls jest or npm ls react-scripts (if you haven鈥檛 ejected): [fill]
  4. your vscode-jest settings if customized:

    • jest.pathToJest? [fill]
    • jest.pathToConfig? [fill]
    • anything else that you think might be relevant? [fill]
  5. Operating system: [fill]

Prerequisite

  • are you able to run jest test from command line? [fill]
  • how do you run your tests from command line? (for example: npm run test or node_modules/.bin/jest) [fill]

Steps to Reproduce

[fill]

Relevant Debug Info

[fill]

Expected Behavior

[fill]

Actual Behavior

[fill]


The fastest (and the most fun) way to resolve the issue is to submit a pull-request yourself. If you are interested, feel free to check out the contribution guide, we look forward to seeing your PR...

Most helpful comment

Is possible to run only on the currently opened test file?

In theory, once you turned off the jest.runAllTestsFirst, jest should only run the tests that "changed". However, if you want to run the files opened, regardless if they are changed, which sounded like an 'on-demand" testing... such feature doesn't exist yet... although I can see it could be useful for some use case... PR is welcome.

All 6 comments

this extension runs your test in 2 phase:

  1. upon starting, it will do a full jest run for all of your tests
  2. followed by starting jest in watch mode, which will only run tests that changed.

You can use "jest.runAllTestsFirst": falseto skip the first full test run.

@connectdotz I'm working in a huge project whereas running Jest in all files takes forever (and often freezes the PC).
Is possible to run only on the currently opened test file?

Is possible to run only on the currently opened test file?

In theory, once you turned off the jest.runAllTestsFirst, jest should only run the tests that "changed". However, if you want to run the files opened, regardless if they are changed, which sounded like an 'on-demand" testing... such feature doesn't exist yet... although I can see it could be useful for some use case... PR is welcome.

This is possible now, please feel free to give v4.0.0-alpha.5 a try and let us know if it works for you.

@connectdotz How can I install this alpha version?

The last one that shows up for me is the 3.2.0
image

@raphaelbs it's not officially released in the marketplace yet, but you can install it using the VSIX file, please see "How to test" section in v4.0.0-alpha.5 release note.

Was this page helpful?
0 / 5 - 0 ratings