Skip to content

Instantly share code, notes, and snippets.

@scottopell
Created March 31, 2018 15:27
Show Gist options
  • Save scottopell/f71ee6cd8ff09c67e59df85704f5364a to your computer and use it in GitHub Desktop.
Save scottopell/f71ee6cd8ff09c67e59df85704f5364a to your computer and use it in GitHub Desktop.
How to debug jest tests with create-react-app-ts scripts
// This took me way too long to figure out.
// Needs node 8.4.0 or greater to work (I think, based on https://github.com/nodejs/node/issues/7593#issuecomment-322966866)
// The magic sauce here is that react-scripts-ts/scripts/test.js creates an inline jest config
// that it passes through. This does things like map css files properly, so if you try to use
// jest directly then it won't work.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest Tests",
"program": "${workspaceFolder}/node_modules/react-scripts-ts/scripts/test.js",
"args": [
"--env=jsdom",
"--runInBand"
],
"env": {
"CI": "true"
},
"internalConsoleOptions": "openOnSessionStart"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment