Skip to content

Commit

Permalink
cherry-pick(#16396): fix(test runner): show interrupted as yellow (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Aug 10, 2022
1 parent 150a751 commit 7de99f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/playwright-test/src/reporters/base.ts
Expand Up @@ -143,9 +143,9 @@ export class BaseReporter implements ReporterInternal {
tokens.push(colors.red(formatTestHeader(this.config, test, ' ')));
}
if (interrupted.length) {
tokens.push(colors.red(` ${interrupted.length} interrupted`));
tokens.push(colors.yellow(` ${interrupted.length} interrupted`));
for (const test of interrupted)
tokens.push(colors.red(formatTestHeader(this.config, test, ' ')));
tokens.push(colors.yellow(formatTestHeader(this.config, test, ' ')));
}
if (flaky.length) {
tokens.push(colors.yellow(` ${flaky.length} flaky`));
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-test/src/runner.ts
Expand Up @@ -950,7 +950,7 @@ function createDuplicateTitlesError(config: FullConfigInternal, rootSuite: Suite
for (const fullTitle of testsByFullTitle.keys()) {
const tests = testsByFullTitle.get(fullTitle);
if (tests.length > 1) {
lines.push(` - title: ${fullTitle}`);
lines.push(` - title: ${fullTitle.replace(/\u001e/g, ' › ')}`);
for (const test of tests)
lines.push(` - ${buildItemLocation(config.rootDir, test)}`);
}
Expand Down
12 changes: 8 additions & 4 deletions tests/playwright-test/runner.spec.ts
Expand Up @@ -20,15 +20,19 @@ test('it should not allow multiple tests with the same name per suite', async ({
const result = await runInlineTest({
'tests/example.spec.js': `
const { test } = pwt;
test('i-am-a-duplicate', async () => {});
test('i-am-a-duplicate', async () => {});
test.describe('suite', () => {
test('i-am-a-duplicate', async () => {});
});
test.describe('suite', () => {
test('i-am-a-duplicate', async () => {});
});
`
});
expect(result.exitCode).toBe(1);
expect(result.output).toContain('duplicate test titles are not allowed');
expect(result.output).toContain(`- title: i-am-a-duplicate`);
expect(result.output).toContain(` - tests${path.sep}example.spec.js:6`);
expect(result.output).toContain(`- title: suite › i-am-a-duplicate`);
expect(result.output).toContain(` - tests${path.sep}example.spec.js:7`);
expect(result.output).toContain(` - tests${path.sep}example.spec.js:10`);
});

test('it should not allow multiple tests with the same name in multiple files', async ({ runInlineTest }) => {
Expand Down

0 comments on commit 7de99f3

Please sign in to comment.