mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-13 07:35:33 +03:00
chore(test-runner): better error message if page gets used inside beforeAll (#16012)
This commit is contained in:
parent
b479869ddc
commit
a089bf3df5
@ -463,8 +463,13 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
|
||||
|
||||
await use(async options => {
|
||||
const hook = hookType(testInfo);
|
||||
if (hook)
|
||||
throw new Error(`"context" and "page" fixtures are not supported in ${hook}. Use browser.newContext() instead.`);
|
||||
if (hook) {
|
||||
throw new Error([
|
||||
`"context" and "page" fixtures are not supported in "${hook}" since they are created on a per-test basis.`,
|
||||
`If you would like to reuse a single page between tests, create context manually with browser.newContext(). See https://aka.ms/playwright/reuse-page for details.`,
|
||||
`If you would like to configure your page before each test, do that in beforeEach hook instead.`,
|
||||
].join('\n'));
|
||||
}
|
||||
const videoOptions: BrowserContextOptions = captureVideo ? {
|
||||
recordVideo: {
|
||||
dir: _artifactsDir(),
|
||||
|
@ -428,7 +428,7 @@ test('should throw when using page in beforeAll', async ({ runInlineTest }, test
|
||||
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.passed).toBe(0);
|
||||
expect(result.output).toContain(`Error: "context" and "page" fixtures are not supported in beforeAll. Use browser.newContext() instead.`);
|
||||
expect(result.output).toContain(`Error: "context" and "page" fixtures are not supported in "beforeAll"`);
|
||||
});
|
||||
|
||||
test('should report click error on sigint', async ({ runInlineTest }) => {
|
||||
|
Loading…
Reference in New Issue
Block a user