fix(test runner): make sure static annotations are reported for skipped tests (#26634)

Fixes #26397.
This commit is contained in:
Dmitry Gozman 2023-08-23 08:40:12 -07:00 committed by GitHub
parent f4f9e526a2
commit 218955c155
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 1 deletions

View File

@ -68,6 +68,7 @@ export function bindFileSuiteToProject(project: FullProjectInternal, suite: Suit
} }
test.retries = inheritedRetries ?? project.project.retries; test.retries = inheritedRetries ?? project.project.retries;
test.timeout = inheritedTimeout ?? project.project.timeout; test.timeout = inheritedTimeout ?? project.project.timeout;
test.annotations = [...test._staticAnnotations];
// Skip annotations imply skipped expectedStatus. // Skip annotations imply skipped expectedStatus.
if (test._staticAnnotations.some(a => a.type === 'skip' || a.type === 'fixme')) if (test._staticAnnotations.some(a => a.type === 'skip' || a.type === 'fixme'))

View File

@ -292,6 +292,7 @@ export class TestCase extends Base implements reporterTypes.TestCase {
poolDigest: this._poolDigest, poolDigest: this._poolDigest,
workerHash: this._workerHash, workerHash: this._workerHash,
staticAnnotations: this._staticAnnotations.slice(), staticAnnotations: this._staticAnnotations.slice(),
annotations: this.annotations.slice(),
projectId: this._projectId, projectId: this._projectId,
}; };
} }
@ -307,6 +308,7 @@ export class TestCase extends Base implements reporterTypes.TestCase {
test._poolDigest = data.poolDigest; test._poolDigest = data.poolDigest;
test._workerHash = data.workerHash; test._workerHash = data.workerHash;
test._staticAnnotations = data.staticAnnotations; test._staticAnnotations = data.staticAnnotations;
test.annotations = data.annotations;
test._projectId = data.projectId; test._projectId = data.projectId;
return test; return test;
} }

View File

@ -76,7 +76,6 @@ export class Dispatcher {
const result = test._appendTestResult(); const result = test._appendTestResult();
result.status = 'skipped'; result.status = 'skipped';
this._reporter.onTestBegin(test, result); this._reporter.onTestBegin(test, result);
test.annotations = [...test._staticAnnotations];
this._reportTestEnd(test, result); this._reportTestEnd(test, result);
} }
this._queue.shift(); this._queue.shift();

View File

@ -619,3 +619,30 @@ test('should skip tests if beforeEach has skip', async ({ runInlineTest }) => {
expectTest('no marker', 'skipped', 'skipped', ['skip']); expectTest('no marker', 'skipped', 'skipped', ['skip']);
expect(result.output).not.toContain('skip-me'); expect(result.output).not.toContain('skip-me');
}); });
test('static modifiers should be added in serial mode', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.test.ts': `
import { test } from '@playwright/test';
test.describe.configure({ mode: 'serial' });
test('failed', async ({}) => {
test.slow();
throw new Error('blocking error');
});
test.fixme('fixmed', async ({}) => {
});
test.skip('skipped', async ({}) => {
});
test('ignored', async ({}) => {
});
`,
});
expect(result.exitCode).toBe(1);
expect(result.passed).toBe(0);
expect(result.skipped).toBe(3);
expect(result.report.suites[0].specs[0].tests[0].annotations).toEqual([{ type: 'slow' }]);
expect(result.report.suites[0].specs[1].tests[0].annotations).toEqual([{ type: 'fixme' }]);
expect(result.report.suites[0].specs[2].tests[0].annotations).toEqual([{ type: 'skip' }]);
expect(result.report.suites[0].specs[3].tests[0].annotations).toEqual([]);
});