Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: make sure skipped tests in serial mode are reported #30484

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion tests/playwright-test/reporter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class Reporter {
}

onTestEnd(test, result) {
console.log('onTestEnd: ' + formatTitle(test) + '; retry #' + result.retry);
const status = this.options.printTestStatus ? '[' + result.status + '] ' : '';
console.log('onTestEnd: ' + status + formatTitle(test) + '; retry #' + result.retry);
this.printErrors(result.errors);
}

Expand Down Expand Up @@ -676,3 +677,39 @@ test('should report annotations from test declaration', async ({ runInlineTest }
`title=fixme-bar-suite, annotations=bar,fixme`,
]);
});

test('tests skipped in serial mode receive onTestBegin/onTestEnd', async ({ runInlineTest }) => {
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/28321' });

const result = await runInlineTest({
'reporter.ts': smallReporterJS,
'playwright.config.ts': `module.exports = { reporter: [['./reporter', { printTestStatus: true }]] };`,
'a.spec.ts': `
import { test, expect } from '@playwright/test';

test.describe.configure({ mode: 'serial', retries: 1 });

test('test1', () => {
expect(test.info().retry).toBe(1);
});

test('test2', () => {
});
`,
}, { 'reporter': '', 'workers': 1 });

expect(result.output).toBe(`
onBegin: 2 tests total
onTestBegin: > a.spec.ts > test1; retry #0
onTestEnd: [failed] > a.spec.ts > test1; retry #0
error: Error: expect(received).toBe(expected) // Object.is equality @ a.spec.ts:7
onTestBegin: > a.spec.ts > test2; retry #0
onTestEnd: [skipped] > a.spec.ts > test2; retry #0
onTestBegin: > a.spec.ts > test1; retry #1
onTestEnd: [passed] > a.spec.ts > test1; retry #1
onTestBegin: > a.spec.ts > test2; retry #1
onTestEnd: [passed] > a.spec.ts > test2; retry #1
onEnd
onExit
`);
});
Loading