Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/test/testType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class TestTypeImpl {
}

private _createTest(type: 'default' | 'only', location: Location, title: string, fn: Function) {
throwIfRunningInsideJest();
const suite = currentlyLoadingFileSuite();
if (!suite)
throw new Error(`test() can only be called in a test file`);
Expand All @@ -71,6 +72,7 @@ export class TestTypeImpl {
}

private _describe(type: 'default' | 'only', location: Location, title: string, fn: Function) {
throwIfRunningInsideJest();
const suite = currentlyLoadingFileSuite();
if (!suite)
throw new Error(`describe() can only be called in a test file`);
Expand Down Expand Up @@ -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([]);