fix(test-runner): warn users who invoke the test-runner with Jest (#7743)
This commit is contained in:
parent
3c4ef9f11d
commit
9e3ac1f3a2
|
|
@ -55,6 +55,7 @@ export class TestTypeImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _createTest(type: 'default' | 'only', location: Location, title: string, fn: Function) {
|
private _createTest(type: 'default' | 'only', location: Location, title: string, fn: Function) {
|
||||||
|
throwIfRunningInsideJest();
|
||||||
const suite = currentlyLoadingFileSuite();
|
const suite = currentlyLoadingFileSuite();
|
||||||
if (!suite)
|
if (!suite)
|
||||||
throw new Error(`test() can only be called in a test file`);
|
throw new Error(`test() can only be called in a test file`);
|
||||||
|
|
@ -71,6 +72,7 @@ export class TestTypeImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _describe(type: 'default' | 'only', location: Location, title: string, fn: Function) {
|
private _describe(type: 'default' | 'only', location: Location, title: string, fn: Function) {
|
||||||
|
throwIfRunningInsideJest();
|
||||||
const suite = currentlyLoadingFileSuite();
|
const suite = currentlyLoadingFileSuite();
|
||||||
if (!suite)
|
if (!suite)
|
||||||
throw new Error(`describe() can only be called in a test file`);
|
throw new Error(`describe() can only be called in a test file`);
|
||||||
|
|
@ -151,4 +153,14 @@ export class TestTypeImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function throwIfRunningInsideJest() {
|
||||||
|
if (process.env.JEST_WORKER_ID) {
|
||||||
|
throw new Error(
|
||||||
|
`Playwright Test needs to be invoked via 'npx playwright test' and excluded from Jest test runs.\n` +
|
||||||
|
`Creating one directory for Playwright tests and one for Jest is the recommended way of doing it.\n` +
|
||||||
|
`See https://playwright.dev/docs/intro/ for more information about Playwright Test.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const rootTestType = new TestTypeImpl([]);
|
export const rootTestType = new TestTypeImpl([]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue