-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
[Feature]: An option to NOT shutdown worker after test failure #32803
Comments
Is there any workaround for this? I already put in work to get beforeAll / afterAll to execute once per file on first worker only, but was shocked to discover that the worker is destroyed on failure. This makes porting to playwright near impossible unless we disable parallelism. And even then it would have terrible performance on test failure since each test failure would run beforeAll / afterAll when really it only needs to run once - a failure shouldn't affect the state of beforeAll so it seems redundant to run it again. |
This is a workaround I've shared in another issue: #22520 (comment) |
Thanks for this! The .afterAll is the tricky part I can't get working well with the destroying worker on failure case. For now I've settled on the following:
So when things are good we get the full benefits of parallelism but when things fail, fall back to how playwright wants things to work (losing all the speed benefits unfortunately). |
Can this be fixed in version 1.51? We're unable to proceed with end-to-end automation for our products due to this blocker. @dgozman |
Please, inform on the decision in respect of the issue. It really is a problem for test automation on our project |
I made a PR to fix this issue, please let me know any feedback you may have |
Tried your changes, the worker is indeed recreated - browser does not close on failure. Which is awesome news! Thanks! |
Great to hear! Actually in your case that's the worker not being recreated |
🚀 Feature Request
Currently Playwright always creates a new worker if test fails:
Although such behavior is quite reasonable, it has some downsides:
beforeAll
also re-run that can be confusing for users, see [QUESTION] How do run beforeAll just once in fully-parallel mode? #22520In most of my tests, I don't store any state in the worker. I just use test scoped fixtures that are re-created for every test anyway. For such cases, an option to re-use worker would significantly improve the performance.
Strictly speaking, current approach does not guarantee 100% pristine environment even for passed tests. In the following example
test 2
fails becausetest 1
changes global state of regexp:Example
I propose to add an option
recreateWorker
that can hold one of two values:on-failure
(current behavior, default)never
(not shutdown worker on failure)For example:
Motivation
When tests don't store any state in worker, having an option to re-use worker after failures with greatly improve performance.
The text was updated successfully, but these errors were encountered: