assert on title
This commit is contained in:
parent
d7b52fbed7
commit
b24f625578
|
|
@ -99,8 +99,9 @@ export function createGlobalSetupTasks(config: FullConfigInternal) {
|
|||
tasks.push(createRemoveOutputDirsTask());
|
||||
tasks.push(...createPluginSetupTasks(config));
|
||||
if (config.globalSetups.length || config.globalTeardowns.length) {
|
||||
for (let i = 0; i < Math.max(config.globalSetups.length, config.globalTeardowns.length); i++)
|
||||
tasks.push(createGlobalSetupTask(i, config));
|
||||
const length = Math.max(config.globalSetups.length, config.globalTeardowns.length);
|
||||
for (let i = 0; i < length; i++)
|
||||
tasks.push(createGlobalSetupTask(i, length));
|
||||
}
|
||||
return tasks;
|
||||
}
|
||||
|
|
@ -163,19 +164,14 @@ function createPluginBeginTask(plugin: TestRunnerPluginRegistration): Task<TestR
|
|||
};
|
||||
}
|
||||
|
||||
function createGlobalSetupTask(index: number, config: FullConfigInternal): Task<TestRun> {
|
||||
function createGlobalSetupTask(index: number, length: number): Task<TestRun> {
|
||||
let globalSetupResult: any;
|
||||
let globalSetupFinished = false;
|
||||
let teardownHook: any;
|
||||
|
||||
let title = 'global setup';
|
||||
if (config.globalSetups.length > 1 || config.globalSetups.length > 1) {
|
||||
const files = [
|
||||
config.globalSetups[index],
|
||||
config.globalTeardowns[index],
|
||||
].filter(Boolean).join(', ');
|
||||
title += ` (${files})`;
|
||||
}
|
||||
if (length)
|
||||
title += ` #${index}`;
|
||||
|
||||
return {
|
||||
title,
|
||||
|
|
|
|||
|
|
@ -427,3 +427,26 @@ test('globalSetup should support multiple', async ({ runInlineTest }) => {
|
|||
'globalTeardown1',
|
||||
]);
|
||||
});
|
||||
|
||||
test('debug logs show index of setup/teardown', async ({ runInlineTest }) => {
|
||||
const { output } = await runInlineTest({
|
||||
'playwright.config.ts': `
|
||||
module.exports = {
|
||||
globalSetup: ['./globalSetup1.ts','./globalSetup2.ts'],
|
||||
globalTeardown: ['./globalTeardown1.ts', './globalTeardown2.ts'],
|
||||
};
|
||||
`,
|
||||
'globalSetup1.ts': `module.exports = () => console.log('globalSetup1');`,
|
||||
'globalSetup2.ts': `module.exports = () => console.log('globalSetup2');`,
|
||||
'globalTeardown1.ts': `module.exports = () => console.log('globalTeardown1');`,
|
||||
'globalTeardown2.ts': `module.exports = () => console.log('globalTeardown2');`,
|
||||
|
||||
'a.test.js': `
|
||||
import { test } from '@playwright/test';
|
||||
test('a', () => console.log('test a'));
|
||||
`,
|
||||
}, { reporter: 'line' }, { DEBUG: 'pw:test:task' });
|
||||
|
||||
expect(output).toContain('pw:test:task "global setup #0" started');
|
||||
expect(output).toContain('pw:test:task "teardown for global setup #0" started');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue