Run the specs with:
$ node --inspect-brk node_modules/.bin/jest --runInBand
Add this config to VSCode:
{
"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", "--env=jsdom"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
Then click play in the debugger.
Postfix test
or it
with .only
:
test.only('foo', () => {
expect('foo').toEqual('foo');
});
You also need to pass the single filename to jest. With CreateReactApp:
$ yarn test my-file.spec.js