cherry-pick(#31426): fix(runner): do not run beforeEach hooks upon skip modifier
This commit is contained in:
parent
4f3f6eecae
commit
4ccaef69be
|
|
@ -570,6 +570,9 @@ export class WorkerMain extends ProcessRunner {
|
||||||
if (error instanceof TimeoutManagerError)
|
if (error instanceof TimeoutManagerError)
|
||||||
throw error;
|
throw error;
|
||||||
firstError = firstError ?? error;
|
firstError = firstError ?? error;
|
||||||
|
// Skip in modifier prevents others from running.
|
||||||
|
if (error instanceof SkipError)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstError)
|
if (firstError)
|
||||||
|
|
|
||||||
|
|
@ -690,3 +690,25 @@ test('static modifiers should be added in serial mode', async ({ runInlineTest }
|
||||||
expect(result.report.suites[0].specs[2].tests[0].annotations).toEqual([{ type: 'skip' }]);
|
expect(result.report.suites[0].specs[2].tests[0].annotations).toEqual([{ type: 'skip' }]);
|
||||||
expect(result.report.suites[0].specs[3].tests[0].annotations).toEqual([]);
|
expect(result.report.suites[0].specs[3].tests[0].annotations).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should skip beforeEach hooks upon modifiers', async ({ runInlineTest }) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'a.test.ts': `
|
||||||
|
import { test } from '@playwright/test';
|
||||||
|
test('top', () => {});
|
||||||
|
|
||||||
|
test.describe(() => {
|
||||||
|
test.skip(({ viewport }) => true);
|
||||||
|
test.beforeEach(() => { throw new Error(); });
|
||||||
|
|
||||||
|
test.describe(() => {
|
||||||
|
test.beforeEach(() => { throw new Error(); });
|
||||||
|
test('test', () => {});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.passed).toBe(1);
|
||||||
|
expect(result.skipped).toBe(1);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue