chore: differentiate test.skip and step.skip (#35002)
This commit is contained in:
parent
98443e5749
commit
85c6405093
|
@ -220,7 +220,7 @@ export class TestInfoImpl implements TestInfo {
|
|||
this._timeoutManager.slow();
|
||||
} else if (type === 'skip' || type === 'fixme') {
|
||||
this.expectedStatus = 'skipped';
|
||||
throw new SkipError('Test is skipped: ' + (description || ''));
|
||||
throw new TestSkipError('Test is skipped: ' + (description || ''));
|
||||
} else if (type === 'fail') {
|
||||
if (this.expectedStatus !== 'skipped')
|
||||
this.expectedStatus = 'failed';
|
||||
|
@ -363,7 +363,7 @@ export class TestInfoImpl implements TestInfo {
|
|||
try {
|
||||
await cb();
|
||||
} catch (e) {
|
||||
if (this._allowSkips && (e instanceof SkipError)) {
|
||||
if (this._allowSkips && (e instanceof TestSkipError)) {
|
||||
if (this.status === 'passed')
|
||||
this.status = 'skipped';
|
||||
} else {
|
||||
|
@ -523,7 +523,7 @@ export class TestStepInfoImpl implements TestStepInfo {
|
|||
try {
|
||||
return await body(this);
|
||||
} catch (e) {
|
||||
if (e instanceof SkipError)
|
||||
if (e instanceof StepSkipError)
|
||||
return undefined as T;
|
||||
throw e;
|
||||
}
|
||||
|
@ -544,11 +544,14 @@ export class TestStepInfoImpl implements TestStepInfo {
|
|||
return;
|
||||
const description = args[1] as (string|undefined);
|
||||
this.annotations.push({ type: 'skip', description });
|
||||
throw new SkipError(description);
|
||||
throw new StepSkipError(description);
|
||||
}
|
||||
}
|
||||
|
||||
export class SkipError extends Error {
|
||||
export class TestSkipError extends Error {
|
||||
}
|
||||
|
||||
export class StepSkipError extends Error {
|
||||
}
|
||||
|
||||
const stepSymbol = Symbol('step');
|
||||
|
|
|
@ -22,7 +22,7 @@ import { setCurrentTestInfo, setIsWorkerProcess } from '../common/globals';
|
|||
import { stdioChunkToParams } from '../common/ipc';
|
||||
import { debugTest, relativeFilePath } from '../util';
|
||||
import { FixtureRunner } from './fixtureRunner';
|
||||
import { SkipError, TestInfoImpl } from './testInfo';
|
||||
import { TestSkipError, TestInfoImpl } from './testInfo';
|
||||
import { testInfoError } from './util';
|
||||
import { inheritFixtureNames } from '../common/fixtures';
|
||||
import { PoolBuilder } from '../common/poolBuilder';
|
||||
|
@ -558,7 +558,7 @@ export class WorkerMain extends ProcessRunner {
|
|||
} catch (error) {
|
||||
firstError = firstError ?? error;
|
||||
// Skip in beforeAll/modifier prevents others from running.
|
||||
if (type === 'beforeAll' && (error instanceof SkipError))
|
||||
if (type === 'beforeAll' && (error instanceof TestSkipError))
|
||||
break;
|
||||
if (type === 'beforeAll' && !this._skipRemainingTestsInSuite) {
|
||||
// This will inform dispatcher that we should not run more tests from this group
|
||||
|
@ -596,7 +596,7 @@ export class WorkerMain extends ProcessRunner {
|
|||
} catch (error) {
|
||||
firstError = firstError ?? error;
|
||||
// Skip in modifier prevents others from running.
|
||||
if (error instanceof SkipError)
|
||||
if (error instanceof TestSkipError)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1628,6 +1628,25 @@ hook |After Hooks
|
|||
`);
|
||||
});
|
||||
|
||||
test('should differentiate test.skip and step.skip', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'reporter.ts': stepIndentReporter,
|
||||
'playwright.config.ts': `module.exports = { reporter: './reporter' };`,
|
||||
'a.test.ts': `
|
||||
import { test, expect } from '@playwright/test';
|
||||
test('test', async ({ }) => {
|
||||
await test.step('outer step', async () => {
|
||||
await test.info().skip();
|
||||
});
|
||||
});
|
||||
`
|
||||
}, { reporter: '' });
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.report.stats.expected).toBe(0);
|
||||
expect(result.report.stats.unexpected).toBe(0);
|
||||
expect(result.report.stats.skipped).toBe(1);
|
||||
});
|
||||
|
||||
test('show api calls inside expects', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
|
|
Loading…
Reference in New Issue