Search code examples
node.jsvisual-studio-codejestjsistanbul

How can I stop being blocked by debugger statements in Jest?


I'm just beginning to use Jest in my nodejs project. I have several test and all pass, but the last test I just coded is passing but is blocked in two places by Jest with code like this:

/* istanbul ignore next */
cov_19rdmie87d().s[43]++;
debugger;

/* istanbul ignore next */
cov_19rdmie87d().s[53]++;
this debugger;

I have to hit f5 to continue twice while running my tests. How can I remove these debugging statements?


Solution

  • Solution: Remove debugger statements from your code and any kind of breakpoints from your inspect sources.

    Some more Wiki on Debugging in JS

    • Debugger : If you place a debugger; line in your code, Chrome will automatically stop there when executing. You can even wrap it in conditionals, so it only runs when you need it.

    • Type debug(item.myFunc) in the console and the script will stop in debug mode when it gets a function call to item.myFunc

    • When you need to debug JavaScript, Chrome lets you pause when a DOM element changes. You can even monitor its attributes. In Chrome Inspector, right-click on the element and pick a break on setting to use.

    For more information, check out this article by raygun on debugging in javascript.