-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Regression]: Can't call test.use() inside a describe() suite of a different test #29734
Comments
Allowing the following code was an oversight on our side. Mixing the test instances (and hooks called on those instances) in the same suite prevents us from keeping the strict semantic. const test = base.extend({ item: async ({}, use) => {} });
base.describe('Admin user', () => {
test('1', async ({ page, item }) => {});
test('2', async ({ page, item }) => {});
}); I'll leave this change open to see how many people are affected by this. |
I updated the release notes to include this as a breaking change. Is there a reason you need to mix test instances? Can you fix the code? |
Also affected here. I've popped a question on the Discord group but cross posting for visibility: I have the following setup for visual testing:
We've found this a nice way to manage our tests, however is the expectation now to have a separate describe block when the test instances change? It's a shame as this seemed to offer quite a maintainable approach to our testing at scale. |
@pavelfeldman There is no particular reason, I just thought it looked neat the way I wrote it. Since it wasn't mentioned in the release notes I wasn't sure if it was an intentional change or not. I can also do this, it was only to avoid having fixtures like (If it is still wrong, since I have different import { test as base } from '@playwright/test';
const test = base.extend({
adminItem: async ({}, use) => {},
normalItem: async ({}, use) => {},
});
test.describe('Admin user', () => {
test.use({ storageState: '/admin/user/path' });
test('1', async ({ page, adminItem }) => {});
test('2', async ({ page, adminItem }) => {});
});
test.describe('Normal user', () => {
test.use({ storageState: '/normal/user/path' });
test('1', async ({ page, normalItem}) => {});
test('2', async ({ page, normalItem }) => {});
}); |
We're affected by this change as well |
We are experiencing difficulties due to this recent update, and we'd like to share our code snippet to highlight its repercussions. Adapting to this change requires significant effort, as it's disrupting the functionality of nearly all our tests. The error we get is
Our setup involves categorizing shows based on user access or the presence of a paywall, or sometimes both. This feature is critical not only for our organization but also for every other organization using Playwright. As others begin upgrading to the latest version, the absence of this feature will undoubtedly have a widespread impact on test organization for all users. Therefore, we kindly request the restoration of this feature to ensure smooth operations for all users.
|
I am also having issues with this change. I was using this to set up an electron app or browser within the same test suite. |
We are affected by this change as well. In our case we have test groupings which, after consuming dynamically the current combination under test, determines a particular version of the test group to be executed. |
We're affected by this change as well. we are using under same describe default "test" and modified "test" fixtures to create test groups |
@pavelfeldman Any updates as to whether this breaking change will be reverted? Our playwright testing framework is built around this functionality, and we would very much like to maintain the current way that it is working, At the moment, we're stuck on version 1.41, and we're in a bit of uncertainty as to what the future holds (whether we will have to change our architectural approach completely or whether we should wait to see if this breaking change will be reverted). |
Yes, same issue |
not sure if it is related or not, but we're on version 1.40 And getting this error:
where we try to do something like the code below. We use fixtures quite heavily and they set up a lot of our entities, but lately we've come to scenarios where we would potentially not want them invoked conditionally per test (so can't use a global setting such as
|
Also affected by this change in a number of our tests. |
Faced with this issue too |
The same issue |
We are facing same issue in our applications. |
Also affected by this, we have put off upgrading playwright until a decision is made here |
Facing the same issue |
We have the same issue. |
I don't like having to duplicate code const test = base.extend({ ... })
const authTest = test.extend({ ... })
// Before
test.describe('desc', () => {
test.beforeEach(() => { ... })
test('test', () => { ... })
authTest('test', () => { ... })
})
// After
test.describe('desc', () => {
test.beforeEach(() => { ... })
test('test', () => { ... })
})
authTest.describe('desc (authenticated)', () => {
authTest.beforeEach(() => { duplicate code })
authTest('test', () => { ... })
}) Probably not ideal but my workaround is to create a fixture that I load strictly for its side effects whenever I want to modify the page context: const test = base.extend<{ __AUTH__: Page }>({
__AUTH__: async({ page }, use) => {
await page.addInitScript(() => {})
await use(page)
},
})
test.describe('desc', () => {
test.beforeEach(() => { ... })
test('test', () => { ... })
test('test', ({ __AUTH__ }) => { await __AUTH__.reload(); ... })
}) Personally I think any extension of a test should be allowed to be nested instead of it. For example: const A = base.extend({ ... })
const A1 = A.extend({ ... })
const B = base.extend({ ... })
A.describe('', () => {
A.test('', () => { }) // works as expected
A1.test('', () => { }) // should be allowed
B.test('', () => { }) // should not be allowed (?)
}) |
My company is also affected by this. |
This also affects some of our utilities |
Affected, downgraded in order to use the last good version. |
Yeah, to me it seems that this is a breaking change and hence shouldn't be included in a minor version regardless of reasoning.
@pavelfeldman could you please explain what exactly you mean here? Maybe there's another solution. |
We're affected by this change as well, any updates? @pavelfeldman |
Can we get an update on this? I'm not able to update @playwright/test to the latest because of this breaking change. Is it going to be reverted, or should we start refactoring all of our tests for this? @pavelfeldman |
This change also affects a project I am working on. |
This change also affects a project I am working on. +1 It would be really really great if it's fixed in the next release version. |
This has affected us toooooooo! |
+1, any update about this? |
@mxschmitt Many people are looking forward to fixing this issue, otherwise our existing playwright won't be able to upgrade to the latest version, so keep an eye on it please, thanks |
+1 waiting... |
+1 |
affected by this change as well, any updates? |
Any workaround for this issue? |
Probably not helpful to add another "me too", yet here I am :( |
I'm also affected by this. We're upgrading from 1.40 to 1.45 and it's affecting how our tests are organized. |
This breaks our tests. In our case we have multi-user tests and separate auth test fixtures for each one. So it looks something like:
We have thousands of tests that depend on this format, not sure how we're going to refactor yet. I could use a single test fixture with test account option but I ran into another issue where you can't call Update: I realized after re-reading the docs that my use case is already covered https://playwright.dev/docs/auth#testing-multiple-roles-with-pom-fixtures So my tests are even better now since they can open both user browser contexts in a single test. For example,
|
+1 affected |
+1 affected. |
+1 affected |
+1 affected. we need to test one feature as different users, also test the same feature which opens above different applications - and it doesnt make sense so split them under different describe. |
+1 affected, would be nice to be able to have test.use() per test, in a single spec file |
We are also affected by this issue, because we are following "https://playwright.dev/docs/test-parallel" to serialise tests in a specific order: test.describe('first test', aFunction) ; |
Any update on whether this is going to be fixed? Seems to have affected a lot of users including myself |
@pavelfeldman Hi, any update? This issue has already affected many people. |
Hi, @pavelfeldman because of this, I can't upgrade to the latest version, why must this limit? |
We were able to fix this issue in our framework. Providing the example below, maybe it will help someone. adminMenu FIXTURE:
Th above fixture imports all the necessary fixtures and exports them as well. IMPORTS
USAGE:
|
Any update on this ? |
+1 affected |
+1 |
1 similar comment
+1 |
Last Good Version
1.41.2
First Bad Version
1.42.0
Steps to reproduce
After updating to playwright
1.42
, I get this message about one of my test files which was fine in1.41.2
:To reproduce, just have describe blocks with extend/use inside of them.
Expected behavior
I expect to be allowed to have use/extend inside a describe block.
Actual behavior
I am not allowed to have use/extend inside a describe block.
Additional context
No response
Environment
The text was updated successfully, but these errors were encountered: