chore: drop the legacy global setup mode (#13803)
This commit is contained in:
parent
c70324d0c0
commit
a01b65bedd
|
|
@ -149,13 +149,6 @@ export class Runner {
|
||||||
this._reporter = await this._createReporter(!!options.listOnly);
|
this._reporter = await this._createReporter(!!options.listOnly);
|
||||||
const config = this._loader.fullConfig();
|
const config = this._loader.fullConfig();
|
||||||
|
|
||||||
let legacyGlobalTearDown: (() => Promise<void>) | undefined;
|
|
||||||
if (process.env.PW_TEST_LEGACY_GLOBAL_SETUP_MODE) {
|
|
||||||
legacyGlobalTearDown = await this._performGlobalSetup(config);
|
|
||||||
if (!legacyGlobalTearDown)
|
|
||||||
return { status: 'failed' };
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await raceAgainstTimeout(() => this._run(!!options.listOnly, options.filePatternFilter || [], options.projectFilter), config.globalTimeout);
|
const result = await raceAgainstTimeout(() => this._run(!!options.listOnly, options.filePatternFilter || [], options.projectFilter), config.globalTimeout);
|
||||||
let fullResult: FullResult;
|
let fullResult: FullResult;
|
||||||
if (result.timedOut) {
|
if (result.timedOut) {
|
||||||
|
|
@ -165,7 +158,6 @@ export class Runner {
|
||||||
fullResult = result.result;
|
fullResult = result.result;
|
||||||
}
|
}
|
||||||
await this._reporter.onEnd?.(fullResult);
|
await this._reporter.onEnd?.(fullResult);
|
||||||
await legacyGlobalTearDown?.();
|
|
||||||
|
|
||||||
// Calling process.exit() might truncate large stdout/stderr output.
|
// Calling process.exit() might truncate large stdout/stderr output.
|
||||||
// See https://github.com/nodejs/node/issues/6456.
|
// See https://github.com/nodejs/node/issues/6456.
|
||||||
|
|
@ -379,12 +371,9 @@ export class Runner {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 13. Run Global setup.
|
// 13. Run Global setup.
|
||||||
let globalTearDown: (() => Promise<void>) | undefined;
|
const globalTearDown = await this._performGlobalSetup(config);
|
||||||
if (!process.env.PW_TEST_LEGACY_GLOBAL_SETUP_MODE) {
|
|
||||||
globalTearDown = await this._performGlobalSetup(config);
|
|
||||||
if (!globalTearDown)
|
if (!globalTearDown)
|
||||||
return { status: 'failed' };
|
return { status: 'failed' };
|
||||||
}
|
|
||||||
|
|
||||||
const result: FullResult = { status: 'passed' };
|
const result: FullResult = { status: 'passed' };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@
|
||||||
|
|
||||||
import { test, expect, stripAnsi } from './playwright-test-fixtures';
|
import { test, expect, stripAnsi } from './playwright-test-fixtures';
|
||||||
|
|
||||||
for (const mode of ['legacy', 'default']) {
|
|
||||||
test.describe(`${mode} mode`, () => {
|
|
||||||
const env = { PW_TEST_LEGACY_GLOBAL_SETUP_MODE: mode === 'legacy' ? '1' : undefined };
|
|
||||||
|
|
||||||
test('globalSetup and globalTeardown should work', async ({ runInlineTest }) => {
|
test('globalSetup and globalTeardown should work', async ({ runInlineTest }) => {
|
||||||
const { results, output } = await runInlineTest({
|
const { results, output } = await runInlineTest({
|
||||||
'playwright.config.ts': `
|
'playwright.config.ts': `
|
||||||
|
|
@ -47,7 +43,7 @@ for (const mode of ['legacy', 'default']) {
|
||||||
expect(process.env.FOO).toBe('42');
|
expect(process.env.FOO).toBe('42');
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
}, undefined, env);
|
});
|
||||||
expect(results[0].status).toBe('passed');
|
expect(results[0].status).toBe('passed');
|
||||||
expect(output).toContain('teardown=42');
|
expect(output).toContain('teardown=42');
|
||||||
});
|
});
|
||||||
|
|
@ -79,13 +75,12 @@ for (const mode of ['legacy', 'default']) {
|
||||||
expect(process.env.FOO).toBe('43');
|
expect(process.env.FOO).toBe('43');
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
}, undefined, env);
|
});
|
||||||
expect(results[0].status).toBe('failed');
|
expect(results[0].status).toBe('failed');
|
||||||
expect(output).toContain('teardown=42');
|
expect(output).toContain('teardown=42');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('globalTeardown does not run when globalSetup times out', async ({ runInlineTest }) => {
|
test('globalTeardown does not run when globalSetup times out', async ({ runInlineTest }) => {
|
||||||
test.skip(!!env.PW_TEST_LEGACY_GLOBAL_SETUP_MODE);
|
|
||||||
const result = await runInlineTest({
|
const result = await runInlineTest({
|
||||||
'playwright.config.ts': `
|
'playwright.config.ts': `
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
@ -110,7 +105,7 @@ for (const mode of ['legacy', 'default']) {
|
||||||
test('should not run', async ({}, testInfo) => {
|
test('should not run', async ({}, testInfo) => {
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
}, undefined, env);
|
});
|
||||||
// We did not run tests, so we should only have 1 skipped test.
|
// We did not run tests, so we should only have 1 skipped test.
|
||||||
expect(result.skipped).toBe(1);
|
expect(result.skipped).toBe(1);
|
||||||
expect(result.passed).toBe(0);
|
expect(result.passed).toBe(0);
|
||||||
|
|
@ -139,7 +134,7 @@ for (const mode of ['legacy', 'default']) {
|
||||||
expect(value).toEqual({ foo: 'bar' });
|
expect(value).toEqual({ foo: 'bar' });
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
}, undefined, env);
|
});
|
||||||
expect(passed).toBe(1);
|
expect(passed).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -166,7 +161,7 @@ for (const mode of ['legacy', 'default']) {
|
||||||
console.log('this test ran');
|
console.log('this test ran');
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
}, { reporter: 'line' }, env);
|
}, { reporter: 'line' });
|
||||||
|
|
||||||
expect(stripAnsi(output)).not.toContain('this test ran');
|
expect(stripAnsi(output)).not.toContain('this test ran');
|
||||||
expect(passed).toBe(0);
|
expect(passed).toBe(0);
|
||||||
|
|
@ -188,7 +183,7 @@ for (const mode of ['legacy', 'default']) {
|
||||||
test('should work', async ({}) => {
|
test('should work', async ({}) => {
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
}, undefined, env);
|
});
|
||||||
expect(output).toContain(`globalSetup.ts: globalSetup file must export a single function.`);
|
expect(output).toContain(`globalSetup.ts: globalSetup file must export a single function.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -216,7 +211,7 @@ for (const mode of ['legacy', 'default']) {
|
||||||
test('should work', async ({}) => {
|
test('should work', async ({}) => {
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
}, undefined, env);
|
});
|
||||||
expect(passed).toBe(1);
|
expect(passed).toBe(1);
|
||||||
expect(exitCode).toBe(0);
|
expect(exitCode).toBe(0);
|
||||||
expect(output).toContain(`%%setup: 42`);
|
expect(output).toContain(`%%setup: 42`);
|
||||||
|
|
@ -244,7 +239,7 @@ for (const mode of ['legacy', 'default']) {
|
||||||
expect(process.env.FOO).toBe('42');
|
expect(process.env.FOO).toBe('42');
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
}, undefined, env);
|
});
|
||||||
expect(results[0].status).toBe('passed');
|
expect(results[0].status).toBe('passed');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -290,7 +285,7 @@ for (const mode of ['legacy', 'default']) {
|
||||||
};
|
};
|
||||||
|
|
||||||
test('globalSetup should work for auth', async ({ runInlineTest }) => {
|
test('globalSetup should work for auth', async ({ runInlineTest }) => {
|
||||||
const result = await runInlineTest(authFiles, undefined, env);
|
const result = await runInlineTest(authFiles);
|
||||||
expect(result.exitCode).toBe(0);
|
expect(result.exitCode).toBe(0);
|
||||||
expect(result.passed).toBe(1);
|
expect(result.passed).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
@ -299,5 +294,3 @@ for (const mode of ['legacy', 'default']) {
|
||||||
const result = await runTSC(authFiles);
|
const result = await runTSC(authFiles);
|
||||||
expect(result.exitCode).toBe(0);
|
expect(result.exitCode).toBe(0);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue