cherry-pick(#16396): fix(test runner): show interrupted as yellow (#16412)

SHA: baa2ef2700
This commit is contained in:
Max Schmitt 2022-08-10 14:53:45 +02:00 committed by GitHub
parent 150a75189e
commit 7de99f3a48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View file

@ -143,9 +143,9 @@ export class BaseReporter implements ReporterInternal {
tokens.push(colors.red(formatTestHeader(this.config, test, ' '))); tokens.push(colors.red(formatTestHeader(this.config, test, ' ')));
} }
if (interrupted.length) { if (interrupted.length) {
tokens.push(colors.red(` ${interrupted.length} interrupted`)); tokens.push(colors.yellow(` ${interrupted.length} interrupted`));
for (const test of 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) { if (flaky.length) {
tokens.push(colors.yellow(` ${flaky.length} flaky`)); tokens.push(colors.yellow(` ${flaky.length} flaky`));

View file

@ -950,7 +950,7 @@ function createDuplicateTitlesError(config: FullConfigInternal, rootSuite: Suite
for (const fullTitle of testsByFullTitle.keys()) { for (const fullTitle of testsByFullTitle.keys()) {
const tests = testsByFullTitle.get(fullTitle); const tests = testsByFullTitle.get(fullTitle);
if (tests.length > 1) { if (tests.length > 1) {
lines.push(` - title: ${fullTitle}`); lines.push(` - title: ${fullTitle.replace(/\u001e/g, ' ')}`);
for (const test of tests) for (const test of tests)
lines.push(` - ${buildItemLocation(config.rootDir, test)}`); lines.push(` - ${buildItemLocation(config.rootDir, test)}`);
} }

View file

@ -20,15 +20,19 @@ test('it should not allow multiple tests with the same name per suite', async ({
const result = await runInlineTest({ const result = await runInlineTest({
'tests/example.spec.js': ` 'tests/example.spec.js': `
const { test } = pwt; const { test } = pwt;
test('i-am-a-duplicate', async () => {}); test.describe('suite', () => {
test('i-am-a-duplicate', async () => {}); test('i-am-a-duplicate', async () => {});
});
test.describe('suite', () => {
test('i-am-a-duplicate', async () => {});
});
` `
}); });
expect(result.exitCode).toBe(1); expect(result.exitCode).toBe(1);
expect(result.output).toContain('duplicate test titles are not allowed'); expect(result.output).toContain('duplicate test titles are not allowed');
expect(result.output).toContain(`- title: i-am-a-duplicate`); expect(result.output).toContain(`- title: suite i-am-a-duplicate`);
expect(result.output).toContain(` - tests${path.sep}example.spec.js:6`);
expect(result.output).toContain(` - tests${path.sep}example.spec.js:7`); 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 }) => { test('it should not allow multiple tests with the same name in multiple files', async ({ runInlineTest }) => {