[FeatureRequest] Allow jest to be ran without watch mode.
See original GitHub issueIt seems like the only way to get jest to run in without watch mode is to run it with --coverage
or set the environment variable to CI=true
. Running npm test -- --watch=false
(and similar) does not work.
My use case for this feature is debugging within VS Code through react scripts.
The following launch configuration was given in the create-react-app docs
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug CRA Tests",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts",
"args": [
"test",
"--runInBand",
"--no-cache"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
This somewhat works but it does not break at breakpoints because (I think) react-scripts is runs jest in watch mode. Adding "env": { "CI": "true" },
allows breakpoints to work again because it disables watch mode.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Create react app debugging",
"type": "node",
"request": "launch",
"env": { "CI": "true" }, // this makes breakpoints work
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts",
"args": ["test", "--runInBand", "--no-cache"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
I’m fine with this workaround but I’d happier with a --watch=false
, --no-watch
, --single
, or similar flag.
Thanks for the amazing tool and I apologize if I missed anything!
Somewhat related issues:
https://github.com/facebook/create-react-app/issues/784 https://github.com/facebook/create-react-app/issues/1137
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top GitHub Comments
We need to bump to
jest@24
, agreed @rally25rs. For now though, ano-watch
flag would help a lot of people.@mrmckeb #2393 and https://github.com/facebook/jest/issues/3254 are the issues I’m trying to resolve. In a very simple new react app (crate-react-app plus react-router and react-bootstrap; and the project has 2 views in it so far just to test out react-router):
the issue seems to be that
react-scripts
forcesjest --watch
andjest
then tries to watch every file innode_modules
(i base this on the comments of these linked issues. it seems to make sense anyway, as my actual project not includingnode_modules
only has a couple dozen files)In the linked issue there is a comment that this is fixed in
jest@24
butreact-scripts
errors if you use any version but23.6.0
. It also prevents you from setting the jest config option watchPathIgnorePatterns which you could use to tell jest to no longer watch files innode_modules
. There is also no way to run jest without--watch
and avoid this altogether.react@16.7.0 react-scripts@2.1.3 jest@23.6.0