Comments (4)
@vitalets Thank you for the issue!
In general, this is the intended behavior. Once a fixture times out, we run out of time budget to teardown other fixtures. Previously, this worked in a limited number of scenarios, where we would teardown the worker and give it some more time to teardown the fixtures. This only worked when the first fixture won't stall forever, but actually finish given a bit more time, which makes it even less useful. Also, this does not play nicely with things like afterAll()
that need all fixtures to be teared down before they can run, and so we cannot introduce extra timeouts there.
It would be nice to understand your usecase - why do you rely on the second fixture teardown to be executed? Perhaps we can improve the situation a bit when there are no hooks, similarly to the old behavior. However, the second timeout will definitely prevent anything else from running.
from playwright.
@dgozman thanks for the explanation!
My use-case is for playwright-bdd project: after running all user-defined fixtures I always need to attach some metadata to the testInfo. This is needed for the correct reporting, even after timeout.
I've also tried to provide a timeout option for my fixture, but it does not help:
export const test = base.extend<{timeoutedFixture: void, anotherFixture: void}>({
timeoutedFixture: async ({anotherFixture}, use, testInfo) => {
await use();
await new Promise((r) => setTimeout(r, testInfo.timeout + 100));
},
anotherFixture: [async ({}, use) => {
console.log('AnotherFixture: setup');
await use();
console.log('AnotherFixture: teardown'); // <-- I expect this to run, b/c fixture has own timeout and should not care about other fixtures timeouts
}, { timeout: 10000 }],
});
Now I'm thinking about two possible solutions:
- perform empty attachment at the setup phase, and then modify this attachment in-place. Is it reliable enough?
- have some synchronous way to pass data to the reporter, see #30179
For the more common case I think this could be a trade-off: for some users time budget is more important, but for others it's more important to cleanup fixtures that already passed the setup phase, even if it exceeds the timeout. Maybe there can be an option for that?
from playwright.
I've also tried to provide a timeout option for my fixture, but it does not help
This is an interesting idea! Having a separate timeout would resolve concerns about running out of the time budget. I'll take a stab at implementing this.
but for others it's more important to cleanup fixtures that already passed the setup phase, even if it exceeds the timeout. Maybe there can be an option for that?
Yeah, I think the custom fixture timeout is a good enough option that works here 😄
perform empty attachment at the setup phase, and then modify this attachment in-place. Is it reliable enough?
Not sure what exactly do you mean. We support attaching strings or blobs, which are immutable, so you would only be able to rewrite the value somewhere in test runner internals and I'd advise against that.
have some synchronous way to pass data to the reporter,
Again, not sure how the synchronous aspect helps here, unfortunately.
from playwright.
This is an interesting idea! Having a separate timeout would resolve concerns about running out of the time budget. I'll take a stab at implementing this.
Looking forward for it!
perform empty attachment at the setup phase, and then modify this attachment in-place. Is it reliable enough?
Not sure what exactly do you mean. We support attaching strings or blobs, which are immutable, so you would only be able to rewrite the value somewhere in test runner internals and I'd advise against that.
I mean searching for attachment in testInfo.attachments
and modifying it's content. E.g.:
function updateAttachment(name, body) {
const attachment = testInfo.attachments.find(a => a.name === name);
attachment.body = body;
}
I can call updateAttachment()
after each step during test execution, and then there is no need to finally call testInfo.attach()
in fixture teardown. But this is relevant only for my use-case and does not solve this timeout issue in general. And I've checked, modifying attachments does not work 😁
from playwright.
Related Issues (20)
- [Bug]: Executed test is not shown in UI-mode after test is completed HOT 2
- [Bug]: full page screenshot causes page duplicates HOT 1
- [Question] HARs name pattern HOT 2
- [Bug]: Issues with Protocol error (Page.navigate), page.goto: does not work HOT 1
- [Bug]: Headless mode doesn't not have the same behavior HOT 13
- [Docs]: Video HOT 3
- [REGRESSION]: Brand new install of playwright, unable to run chromium with show browser using vscode HOT 2
- [Bug]: Report's total time is incorrect HOT 5
- [Bug]: Performance issue with yarn pnp HOT 3
- [Bug]: Headless mode behavior is different than UI mode HOT 1
- [Bug]: Cannot do 'yarn create playwright --ct' without error HOT 2
- [Feature]: Only show tags in Report which are picked up by `grep`
- [Feature]: Fixed masked element size HOT 1
- [Bug]: trace viewer replaces noscript elements with x-noscript in snapshot viewer HOT 1
- [Feature]: Re-run the last test when manually reloading browser window HOT 1
- "Authenticate with API request" problem. HOT 1
- [Bug]: Authenticate with API request problems. HOT 2
- [Bug]: DEBUG=pw:webserver no longer works (regression) HOT 2
- [Bug]: Locators do not auto-wait when resolved to multiple elements (Strict mode) HOT 4
- [Bug]: UI mode highlights all tests that import fixtures in red, despite running tests correctly; claims they shouldn't be imported HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from playwright.