jest icon indicating copy to clipboard operation
jest copied to clipboard

[Feature]: Jest should use the `debugger` statement on failure

Open Lectem opened this issue 1 year ago • 7 comments

🚀 Feature Proposal

By default, jest should use the debugger statement on assertion failure. This could also be behind a configuration parameter.

Motivation

This would make it way easier when using a debugger to break directly on failing assertions instead of having to put breakpoints manually, or break on all "Caught exceptions" which means you would break on your own exceptions too.

Example

No response

Pitch

Some test is failing and you want to debug it. You run it through the debugger, but the process exits right after the exception failed. You realize you now need to put, manually, a breakpoint after finding the line throwing the assert. Worse, if you happen to have some reusable function that wraps jest's expect call, you might break many times before finally finding the call that actually causes issues. All of this could have been avoided if you let the test framework tell the debugger when to break !

Lectem avatar Jul 08 '24 12:07 Lectem

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Aug 07 '24 13:08 github-actions[bot]

Up

Lectem avatar Aug 07 '24 13:08 Lectem

Huh, interesting feature request! I like it. Not sure where it would be hooked up, tho. In expect?

SimenB avatar Aug 09 '24 14:08 SimenB

Ideally as close to the test code as possible or somewhere you can know what failed I guess. I suppose where the check is actually done would be OK? I'm not familiar enough with jest internals to know about that. In any case one could just go up the stack to find the faulty code!

Lectem avatar Aug 12 '24 17:08 Lectem

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Sep 11 '24 18:09 github-actions[bot]

Keep issue alive

Lectem avatar Sep 11 '24 19:09 Lectem

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Oct 11 '24 20:10 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] avatar Nov 10 '24 21:11 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] avatar Nov 10 '24 21:11 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

github-actions[bot] avatar Dec 11 '24 00:12 github-actions[bot]