-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Bail option to skip all subsequent tests #1459
Comments
Can you explain how you see it? For example, what should happen in those situations:
test('test 1', () => {/* code that fails */})
test('test 2', () => {/* other test */})
describe('describe 1', () => {
test('test 1', () => {/* code that fails */})
test('test 2', () => {/* other test */})
})
describe('describe 2', () => {
test('test 1', () => {/* other test */})
test('test 2', () => {/* other test */})
})
describe('describe 1', () => {
describe('describe 2', () => {
test('test 1', () => {/* code that fails */})
test('test 2', () => {/* other test */})
})
test('test 1', () => {/* other test */})
test('test 2', () => {/* other test */})
})
// spec1.spec.ts
test('test 1', () => {/* code that fails */})
// spec2.spec.ts
test('test 2', () => {/* other test */}) |
skip
skip all the tests in
skip all the tests in
skip all the tests in I think the rule should be:
|
Thank you for your clarification. I have some notes tho.
This wouldn't be possible. One spec file knows nothing about the other, they are isolated (as they should be). And it doesn't really makes sense that test in one file can affect test in another. I also don't like the name "test" for the scope. I personally get confused associating scope Also, should we have some escape hatch for specifying scope |
I thought it was something possible with Jest, as you can nest
Yes maybe
It's a good idea but I would wait a bit for the initial implementation first and have more feedbacks about it. |
As long as they are in the same file, it should work. Spec files don't communicate with each other.
I am ok with As far as I understand, |
May I ask if there is any news? As already mentioned Jest provides a It would save a lot of time in CI pipelines :) |
I'm integrating vitest into the lint-staged pipeline and replacing jest. Would be cool to bail early if there is any failed test. |
Any update on this? I am quite happy with vitest but it can add up a lot of cost for CI pipelines if you get an error in the first minute of execution but subsequent tests keep on running for another 15 minutes. |
PR welcome. |
This comment was marked as outdated.
This comment was marked as outdated.
Is there any specific place folks can look at to introduce For example, here is a function which marks failure for a task in a runner: vitest/packages/runner/src/run.ts Lines 198 to 204 in 895103a
|
This comment was marked as outdated.
This comment was marked as outdated.
Feel free to take up this task, once maintainers confirm the solution posted above is the right way to go ahead or provide alternative suggestions. I'll revisit this issue after a month or so, and can take up if it's not implemented by then. |
This comment was marked as outdated.
This comment was marked as outdated.
I think the check needs to be done in
If you're interested to take up this work, do wait for a comment from maintainers to check if there are better alternatives. |
I don't know. Probably right. Be aware that vitest/packages/runner/src/run.ts Lines 316 to 317 in 895103a
The hardest part here is to tell Vitest to stop running all other workers from within the worker without breaking Tinypool. |
Can we use SharedArrayBuffer to store The blog post Using Shared Array Buffer in Node.js provides an example of how SharedArrayBuffer can be shared between workers. I see that vitest/packages/vitest/src/node/pools/threads.ts Lines 23 to 33 in 895103a
Can this store cc Tinypool author @Aslemammad for comments. |
I think it's for use in |
The |
It looks like the messages can be exchanged between worker threads or child processes using
|
After diving deep into the source code, I think the High level suggestion:
If you're interested to take up this work, do wait for a comment from maintainers to check if there are better alternatives. |
I think this and #3128 could share the mechanic of how test running is stopped. Maybe there should be a way to tell all pools (and their test runners) to stop their execution gracefully. And when a test fails with
|
Clear and concise description of the problem
Depending on the kind of tests we run, it can be interesting to have a fail-fast feature and exit as soon as a test is failing.
I'm not the only one needing such feature apparently: #964
Jest has bail for this purpose.
Suggested solution
As Vitest tries to smooth the transition from Jest, I think the
bail
option is a sensible name.But Jest implementation is incomplete/weird, it's only skipping the next test suites (describe blocks), but it continues to run the other tests within the same test suite.
I think the default should be to bail by test case and not by test suite.
I'm not sure what could be the API if we want to deal with both test cases and test suites, maybe adding a
--bail-scope <test|suite>
(default test)? 🤔Alternative
No response
Additional context
Here are related issues about it:
Validations
The text was updated successfully, but these errors were encountered: