vscode-jest: Can't make it work with Angular CLI and custom Jest builder.

Environment

  1. node -v: v8.12.0
  2. npm -v: 6.4.1
  3. npm ls jest or npm ls react-scripts (if you haven’t ejected): npm ls jest:
`-- jest@23.6.0
  1. your vscode-jest settings if customized:

    • jest.pathToJest: npm test --
    • anything else that you think might be relevant?
  2. Operating system: Windows 10

Prerequisite

  • are you able to run jest test from command line? Yes.
  • how do yo run your tests from command line?
    • npm run test
    • ng test

Steps to Reproduce

// TODO

Relevant Debug Info

spawning process with command=npm, args=test,--,--json,--useStderr,--outputFile,C:\Users\MICHAE~1.DEA\AppData\Local\Temp/jest_runner.json,--no-color
> ng test --watch "--json" "--useStderr" "--outputFile" "C:\Users\SuperCoolUserName\AppData\Local\Temp/jest_runner.json" "--watch" "--no-color"

Expected Behavior

I would expect this to use the configuration from the Angular builder and work.

Actual Behavior

Prints:

No tests found related to files changed since last commit.

Considerations:

I’m using Angular CLI, with Jest configured through @angular-builders/jest package. From command line works as expected using both npm run test, and ng test --watch (npm run test is an alias for the latter). From the npm script panel in VSCode it launches as expected.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 2
  • Comments: 22

Most upvoted comments

Oh! I get now what you mean with auto watch. I think you could try to get it working with a workspace. You can setup each app and lib into its own project in the workspace, and configure each. I have a repo with Lerna, but it’s private for now. I’ll try to upload a example with a clean repo.

Yea; I can’t get your launch.json to work for me; but I created my own that works great with nx. nx is a single repo; but multiple projects; so it’s useful to scope debugging to just the tests on a single library or app rather than the whole thing; which is whay my launch.json does as documented in this gist: https://gist.github.com/toddwseattle/71f1c2b7b439c6523cc543edab030842

What I would like is a way for the auto watch to work so things like the inline red / green dots work; and that I don’t get the problems tabbed filled with un running tests.