-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to skip rest test cases if one fails #8387
Comments
keyword: step |
Duplicate of #6527 (for hooks and tests) |
No it's not a duplicate. We are requesting mocha-steps not jasmine-fail-fast. TL;DR: skip (and auto fail) the following steps after the first failing step within the current describe (not exit on first failure) @jeysal please reopen. |
Okay then, we can keep this open to track fail-fast within a describe block (although the OP does not explicitly request this). |
Personally I think this makes sense, and would love to see it in the jest core under Take for example this test:
It's checking that Since But, since Meanwhile, if we had
This maybe be a result of me being relatively new to the testing game, but it seems to me that I know that I don't mind I'm just really excited at the idea of having this feature in jest, as I've come across this problem a lot! 😄 |
Smoke tests in front of more substantial tests save people time. Without the ability to short circuit subsequent test, the time saving is mitigated. Where does this functionality need to be added? Would this live in a test runner or is this a jest issue? (Many people don't even realize the distinction between jest and test runners...) |
Here is my temporary solution.
|
I would be interested in implementing a test.step function in jest circus, I don't see a way to do this outside of the jest-circus core though, as it requires adding some flag to the state. |
I created a PR that implements asynchronously canceling tests as described in #8604. With that in place, one could implement this functionality through easy monkey patching in user land like this: let prevFailed;
const _describe = global.describe;
global.describe = (...args) => {
prevFailed = false;
return _describe(...args);
};
global.test.step = (name, fn, ...args) => {
test(name, async function(...fnArgs) {
if (prevFailed) {
return this.skip();
}
try {
return await fn(...fnArgs);
} catch (e) {
prevFailed = true;
throw e;
}
}, ...args);
}; |
@MrLoh where's the PR? I only see the issue |
#9944 But I doubt it will ever be merged, I haven't heard back a single word from any contributor. |
My solution to skip rest tests after first failure #6527 (comment) |
Here is my solution #7245 to skip test programmatically and on run time after test began. the key is to call |
Playwright already provides a test.step https://playwright.dev/docs/api/class-test/#test-step |
I have created the Jest Environment for this usecase |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
. |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
. |
. |
🚀 Feature Proposal
Provide ability to skip rest test cases in a file or
describe
block if one test fails.Motivation
For E2E testing, the test cases are usually written to be run sequentially, and a failed test should stop the rest from running.
Example
Or with
describe
s:The text was updated successfully, but these errors were encountered: