[Question] - Hooks and teardown
See original GitHub issueHi guys, quick question, is it always recommended to use test.afterAll or afterEach when using the page fixtures in a spec file ? I have a couple of specs and noticed some issues when running them on azure with the error:
“Test timeout of 30000ms exceeded while tearing down “context”.”
It is intermittent , but seems to have stopped when adding page.close() in the afterEach hook. However, I could see there is no afterEach hook in the example class created automatically when installing playwright (So I was not sure if it is 100% needed or not)
I have one spec with different test cases using the page fixture and another one that loops through a list of values to execute the tests, and it happened in both of them. I.e:
Example1:
text.describe({
test('test1' , async ({page})=> {
//do something
})
test('test2' , async ({page})=> {
//do something else
})
})
Example2:
test.describe({
for(const value of values){
test(`test ${value}`, async ({ page }) => {
await page.goto(`/value`);
});
}
})
Issue Analytics
- State:
- Created a year ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Pytest setup/teardown hooks for session - Stack Overflow
I want to create my custom test environment in setup (before start of test session) and cleanup after all tests will be finished....
Read more >What are Cucumber Hooks And How to Use ... - Tools QA
Cucumber supports hooks, which are blocks of code that run before or after each scenario. You can define them anywhere in your project...
Read more >How to Write a Hook | Writing Studio
A question hook is when you ask the reader something that they can visualize and try to think of in their own minds....
Read more >Understanding Vue.js Lifecycle Hooks - DigitalOcean
Understanding Destruction Hooks (Teardown) ... Destruction hooks allow you to perform actions when your component is destroyed, such as cleanup or ...
Read more >Hooking into the Test Process - Behat
Scenario Hooks¶ · @BeforeScenario hook executes not only before each scenario in each feature, but before each example row in the scenario outline....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

That would be awesome. We didn’t find anything that might affect this kind of behavior change from 1.25 to 1.26, so a repro would drastically help us debug this issue.
Let me close this for now, but please file another issue as you have a repro. (this way we won’t accidentally forget about it).
Thanks!
Seeing the issue on 1.25 intermittently as well, so I definitely assume it has something to do with the app itself. However the Traces and what can be seen on the video confused me a little bit. In the last Trace I got, I can see a page.close() timing out