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(createRemoveOutputDirsTask());
|
||||||
tasks.push(...createPluginSetupTasks(config));
|
tasks.push(...createPluginSetupTasks(config));
|
||||||
if (config.globalSetups.length || config.globalTeardowns.length) {
|
if (config.globalSetups.length || config.globalTeardowns.length) {
|
||||||
for (let i = 0; i < Math.max(config.globalSetups.length, config.globalTeardowns.length); i++)
|
const length = Math.max(config.globalSetups.length, config.globalTeardowns.length);
|
||||||
tasks.push(createGlobalSetupTask(i, config));
|
for (let i = 0; i < length; i++)
|
||||||
|
tasks.push(createGlobalSetupTask(i, length));
|
||||||
}
|
}
|
||||||
return tasks;
|
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 globalSetupResult: any;
|
||||||
let globalSetupFinished = false;
|
let globalSetupFinished = false;
|
||||||
let teardownHook: any;
|
let teardownHook: any;
|
||||||
|
|
||||||
let title = 'global setup';
|
let title = 'global setup';
|
||||||
if (config.globalSetups.length > 1 || config.globalSetups.length > 1) {
|
if (length)
|
||||||
const files = [
|
title += ` #${index}`;
|
||||||
config.globalSetups[index],
|
|
||||||
config.globalTeardowns[index],
|
|
||||||
].filter(Boolean).join(', ');
|
|
||||||
title += ` (${files})`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title,
|
title,
|
||||||
|
|
|
||||||
|
|
@ -427,3 +427,26 @@ test('globalSetup should support multiple', async ({ runInlineTest }) => {
|
||||||
'globalTeardown1',
|
'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