-
Notifications
You must be signed in to change notification settings - Fork 674
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
.afterEach block should still execute when .beforeEach fails #8050
Comments
Thank you for sharing your suggestion. We cannot consider this behavior as a bug. From our perspective, if We think that the correct approach in this case should be the following:
|
That's just asking for ugly code and isn't as efficient as being able to rely on fixture hooks. For reference, Junit works this way. If you don't agree with it being the default behavior is it possible to look into allowing configuration for it? I think doing setup in the .beforeEach and cleaning up in the .afterEach is a very common pattern - adding a try catch on every setup call (there could be many within a single hook) doesn't sound like a good workaround. |
We discussed the issue with the team and decided to keep it closed. In our opinion, in general, it's difficult to determine which data should be cleaned up on the |
What is your Scenario?
I do environment setup in the .beforeEach (adding users for example), and cleanup in the .afterEach(deleting users). If the .beforeEach fails at any point, the .afterEach will not execute and my data is not cleaned up.
What is the Current behavior?
.afterEach will not execute if .beforeEach fails
What is the Expected behavior?
.afterEach should always execute
What is your public website URL? (or attach your complete example)
What is your TestCafe test code?
Your complete configuration file
None needed
Your complete test report
Screenshots
Steps to Reproduce
TestCafe version
3.3.0
Node.js version
18.16.0
Command-line arguments
testcafe 'chrome' 'path\testName.ts' '-c' '1' '--test' 'test1'
Browser name(s) and version(s)
Chrome 118
Platform(s) and version(s)
Windows 11
Other
No response
The text was updated successfully, but these errors were encountered: