
Jest caches transformed module files to speed up test execution. The transform script was changed or Babel was updated and the changes aren't being recognized by Jest?

If you are using Facebook's create-react-app, in the Jest run/debug configuration specify the path to the react-scripts package in the Jest package field and add -env=jsdom to the Jest options field. Save the configuration, put the breakpoints in the code, then click the green debug icon to start debugging. Optionally specify the Jest configuration file, additional options, and environment variables. In the WebStorm menu Run select Edit Configurations. It will launch tests and automatically attach debugger. The easiest way to debug Jest tests in WebStorm is using Jest run/debug configuration. More information on Node debugging can be found here. "runtimeExecutable" : "$/node_modules/.bin/react-scripts" , To attach the built-in debugger, run your tests as aforementioned: There are multiple ways to debug Jest tests with Visual Studio Code's built-in debugger. Normally Jest parallelizes test runs across processes but it is hard to debug many processes at the same time. Note: the -runInBand cli option makes sure Jest runs the test in the same process rather than spawning processes for individual tests. When Jest executes the test that contains the debugger statement, execution will pause and you can examine the current scope and call stack. Click the button that looks like a "play" button in the upper right hand side of the screen to continue execution.

The Chrome Developer Tools will be displayed, and a breakpoint will be set at the first line of the Jest CLI script (this is done to give you time to open the developer tools and to prevent Jest from executing before you have time to do so).

Click on the address displayed in the terminal (usually something like localhost:9229) after running the above command, and you will be able to debug Jest using Chrome's DevTools. To debug in Google Chrome (or any Chromium-based browser), open your browser and go to chrome://inspect and click on "Open Dedicated DevTools for Node", which will give you a list of available node instances you can connect to. Note that the process will pause until the debugger has connected to it. This will run Jest in a Node process that an external debugger can connect to. node_modules/jest/bin/jest.js -runInBand Node -inspect-brk node_modules/.bin/jest -runInBand
