Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(test runner): make sure static annotations are reported for skipped tests (#26634)
Dmitry Gozman218955c1552f
diff --git a/packages/playwright-test/src/common/suiteUtils.ts b/packages/playwright-test/src/common/suiteUtils.tsindex da3714ba7f..7994c10e04 100644--- a/packages/playwright-test/src/common/suiteUtils.ts+++ b/packages/playwright-test/src/common/suiteUtils.ts@@ -68,6 +68,7 @@ export function bindFileSuiteToProject(project: FullProjectInternal, suite: Suit}test.retries = inheritedRetries ?? project.project.retries;test.timeout = inheritedTimeout ?? project.project.timeout;+ test.annotations = [...test._staticAnnotations];// Skip annotations imply skipped expectedStatus.if (test._staticAnnotations.some(a => a.type === 'skip' || a.type === 'fixme'))diff --git a/packages/playwright-test/src/common/test.ts b/packages/playwright-test/src/common/test.tsindex aadcc89781..a1afee5b08 100644--- a/packages/playwright-test/src/common/test.ts+++ b/packages/playwright-test/src/common/test.ts@@ -292,6 +292,7 @@ export class TestCase extends Base implements reporterTypes.TestCase {poolDigest: this._poolDigest,workerHash: this._workerHash,staticAnnotations: this._staticAnnotations.slice(),+ annotations: this.annotations.slice(),projectId: this._projectId,};}@@ -307,6 +308,7 @@ export class TestCase extends Base implements reporterTypes.TestCase {test._poolDigest = data.poolDigest;test._workerHash = data.workerHash;test._staticAnnotations = data.staticAnnotations;+ test.annotations = data.annotations;test._projectId = data.projectId;return test;}diff --git a/packages/playwright-test/src/runner/dispatcher.ts b/packages/playwright-test/src/runner/dispatcher.tsindex dcaf0f6289..42b8a2fa55 100644--- a/packages/playwright-test/src/runner/dispatcher.ts+++ b/packages/playwright-test/src/runner/dispatcher.ts@@ -76,7 +76,6 @@ export class Dispatcher {const result = test._appendTestResult();result.status = 'skipped';this._reporter.onTestBegin(test, result);- test.annotations = [...test._staticAnnotations];this._reportTestEnd(test, result);}this._queue.shift();diff --git a/tests/playwright-test/test-modifiers.spec.ts b/tests/playwright-test/test-modifiers.spec.tsindex c5ed51a488..ce9a1aff9a 100644--- a/tests/playwright-test/test-modifiers.spec.ts+++ b/tests/playwright-test/test-modifiers.spec.ts@@ -619,3 +619,30 @@ test('should skip tests if beforeEach has skip', async ({ runInlineTest }) => {expectTest('no marker', 'skipped', 'skipped', ['skip']);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([]);+});