Vscode-jest: create-react-app

Created on 23 May 2017  Â·  11Comments  Â·  Source: jest-community/vscode-jest

Most helpful comment

Just ran into this problem as well. If you're on windows try setting the jest.pathToJest to npm.cmd run test -- or yarn.cmd test --. Node's spawn doesn't find bat files automatically.

All 11 comments

Does your test script has the flag: --env=jsdom ?

Yes it does @tomtobac, when I run npm run test in terminal, it works fine, but doesn't work in vscode

vscode-jest does not run npm run test - it runs Jest directly, you'll need to change your jest.pathToJest to be npm run test

I have got the exactly same error.
If I set jest.pathToJest to npm run test, the output is Exception raised: Process failed: spawn npm ENOENT

Same errore here Exception raised: Process failed: spawn npm ENOENT when setting jest.pathToJest as npm run test with create-react-app...

Just ran into this problem as well. If you're on windows try setting the jest.pathToJest to npm.cmd run test -- or yarn.cmd test --. Node's spawn doesn't find bat files automatically.

Thanks for your suggestion @silentdragonz , now my tests ran through vscode-jest and I can see inline error messages, but only if I set npm.cmd run test --, not with yarn.cmd.

Anyway one thing I'm missing looking at the example gif are suggestions, but I'm not sure they are part of this package?

@types/jest is the only thing I had to install to get Jest suggestions.

I've tried setting jest.pathToJest to npm test -- as suggested in the docs, as well as a bunch of other variations, but I always get Exception raised: Process failed: spawn node_modules/.bin/jest ENOENT, no matter what I set for jest.pathToJest, as if it's not looking at it at all. I'm on a Mac, not Windows, so the npm.cmd doesn't apply.

My npm scripts contains "test": "react-scripts-ts test --env=jsdom", and I'm also using react-scripts-ts instead of the vanilla react-scripts, so I've been starting/stopping the extension manually, but it has never run a test yet.

I'm also using jest-cli and there is no jest in node_modules/.bin/jest, but there is one in node_modules/react-scripts-ts/node_modules/.bin/jest, but that doesn't work either with jest.pathToJest.

This might be a stupid question but in my case, the output of the Jest plugin only shows this

Watch Usage
 › Press a to run all tests.
 › Press p to filter by a filename regex pattern.
 › Press t to filter by a test name regex pattern.
 › Press q to quit watch mode.
 › Press Enter to trigger a test run.

and it gets stuck in there, I can't press any key...

@silentdragonz Thank you so much. Worked like a Charm.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Drakota picture Drakota  Â·  16Comments

Glutnix picture Glutnix  Â·  37Comments

karb0f0s picture karb0f0s  Â·  37Comments

luisrudge picture luisrudge  Â·  27Comments

dandv picture dandv  Â·  17Comments