mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
parent
f0fc566004
commit
b58b004f0f
@ -144,6 +144,8 @@ export class Runner {
|
||||
else
|
||||
this._reporter.onError?.(createStacklessError(`Timed out waiting ${config.globalTimeout / 1000}s for the entire test run`));
|
||||
return actualResult;
|
||||
} else if (this._didBegin) {
|
||||
await this._reporter.onEnd?.(result.result);
|
||||
}
|
||||
return result.result;
|
||||
} catch (e) {
|
||||
@ -384,13 +386,11 @@ export class Runner {
|
||||
|
||||
if (sigint) {
|
||||
const result: FullResult = { status: 'interrupted' };
|
||||
await this._reporter.onEnd?.(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
const failed = hasWorkerErrors || rootSuite.allTests().some(test => !test.ok());
|
||||
const result: FullResult = { status: failed ? 'failed' : 'passed' };
|
||||
await this._reporter.onEnd?.(result);
|
||||
return result;
|
||||
} finally {
|
||||
if (globalSetupResult && typeof globalSetupResult === 'function')
|
||||
|
@ -176,6 +176,35 @@ test('should work without a file extension', async ({ runInlineTest }) => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('should report onEnd after global teardown', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'reporter.ts': smallReporterJS,
|
||||
'globalSetup.ts': `
|
||||
module.exports = () => {
|
||||
return () => console.log('\\n%%global teardown');
|
||||
};
|
||||
`,
|
||||
'playwright.config.ts': `
|
||||
module.exports = {
|
||||
reporter: './reporter',
|
||||
globalSetup: './globalSetup',
|
||||
};
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = pwt;
|
||||
test('pass', async ({}) => {
|
||||
});
|
||||
`
|
||||
}, { reporter: '', workers: 1 });
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.output.split('\n').filter(line => line.startsWith('%%'))).toEqual([
|
||||
'%%begin',
|
||||
'%%global teardown',
|
||||
'%%end',
|
||||
]);
|
||||
});
|
||||
|
||||
test('should load reporter from node_modules', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'node_modules/my-reporter/index.js': smallReporterJS,
|
||||
|
Loading…
x
Reference in New Issue
Block a user