fix(testMatch): do not count test.ts and spec.ts as test files by default (#22440)
This commit is contained in:
parent
1fecc20238
commit
bf661535a6
|
|
@ -517,7 +517,7 @@ export default defineConfig({
|
|||
|
||||
Only the files matching one of these patterns are executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns.
|
||||
|
||||
By default, Playwright looks for files matching the following glob pattern: `**/?(*.)@(spec|test).?(m)[jt]s?(x)`. This means JavaScript or TypeScript files with `".test"` or `".spec"` suffix, for example `login-screen.spec.ts`.
|
||||
By default, Playwright looks for files matching the following glob pattern: `**/*.@(spec|test).?(m)[jt]s?(x)`. This means JavaScript or TypeScript files with `".test"` or `".spec"` suffix, for example `login-screen.wrong-credentials.spec.ts`.
|
||||
|
||||
**Usage**
|
||||
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ Use [`property: TestConfig.testIgnore`] to change this option for all projects.
|
|||
|
||||
Only the files matching one of these patterns are executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns.
|
||||
|
||||
By default, Playwright looks for files matching the following glob pattern: `**/?(*.)@(spec|test).?(m)[jt]s?(x)`. This means JavaScript or TypeScript files with `".test"` or `".spec"` suffix, for example `login-screen.spec.ts`.
|
||||
By default, Playwright looks for files matching the following glob pattern: `**/*.@(spec|test).?(m)[jt]s?(x)`. This means JavaScript or TypeScript files with `".test"` or `".spec"` suffix, for example `login-screen.wrong-credentials.spec.ts`.
|
||||
|
||||
Use [`property: TestConfig.testMatch`] to change this option for all projects.
|
||||
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ export class FullProjectInternal {
|
|||
testDir,
|
||||
snapshotDir: takeFirst(pathResolve(configDir, projectConfig.snapshotDir), pathResolve(configDir, config.snapshotDir), testDir),
|
||||
testIgnore: takeFirst(projectConfig.testIgnore, config.testIgnore, []),
|
||||
testMatch: takeFirst(projectConfig.testMatch, config.testMatch, '**/?(*.)@(spec|test).?(m)[jt]s?(x)'),
|
||||
testMatch: takeFirst(projectConfig.testMatch, config.testMatch, '**/*.@(spec|test).?(m)[jt]s?(x)'),
|
||||
timeout: takeFirst(configCLIOverrides.timeout, projectConfig.timeout, config.timeout, defaultTimeout),
|
||||
use: mergeObjects(config.use, projectConfig.use, configCLIOverrides.use),
|
||||
dependencies: projectConfig.dependencies || [],
|
||||
|
|
|
|||
15
packages/playwright-test/types/test.d.ts
vendored
15
packages/playwright-test/types/test.d.ts
vendored
|
|
@ -347,8 +347,9 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
|
|||
* Only the files matching one of these patterns are executed as test files. Matching is performed against the
|
||||
* absolute file path. Strings are treated as glob patterns.
|
||||
*
|
||||
* By default, Playwright looks for files matching the following glob pattern: `**\/?(*.)@(spec|test).?(m)[jt]s?(x)`.
|
||||
* This means JavaScript or TypeScript files with `".test"` or `".spec"` suffix, for example `login-screen.spec.ts`.
|
||||
* By default, Playwright looks for files matching the following glob pattern: `**\/*.@(spec|test).?(m)[jt]s?(x)`. This
|
||||
* means JavaScript or TypeScript files with `".test"` or `".spec"` suffix, for example
|
||||
* `login-screen.wrong-credentials.spec.ts`.
|
||||
*
|
||||
* Use [testConfig.testMatch](https://playwright.dev/docs/api/class-testconfig#test-config-test-match) to change this
|
||||
* option for all projects.
|
||||
|
|
@ -1191,8 +1192,9 @@ interface TestConfig {
|
|||
* Only the files matching one of these patterns are executed as test files. Matching is performed against the
|
||||
* absolute file path. Strings are treated as glob patterns.
|
||||
*
|
||||
* By default, Playwright looks for files matching the following glob pattern: `**\/?(*.)@(spec|test).?(m)[jt]s?(x)`.
|
||||
* This means JavaScript or TypeScript files with `".test"` or `".spec"` suffix, for example `login-screen.spec.ts`.
|
||||
* By default, Playwright looks for files matching the following glob pattern: `**\/*.@(spec|test).?(m)[jt]s?(x)`. This
|
||||
* means JavaScript or TypeScript files with `".test"` or `".spec"` suffix, for example
|
||||
* `login-screen.wrong-credentials.spec.ts`.
|
||||
*
|
||||
* **Usage**
|
||||
*
|
||||
|
|
@ -5875,8 +5877,9 @@ interface TestProject {
|
|||
* Only the files matching one of these patterns are executed as test files. Matching is performed against the
|
||||
* absolute file path. Strings are treated as glob patterns.
|
||||
*
|
||||
* By default, Playwright looks for files matching the following glob pattern: `**\/?(*.)@(spec|test).?(m)[jt]s?(x)`.
|
||||
* This means JavaScript or TypeScript files with `".test"` or `".spec"` suffix, for example `login-screen.spec.ts`.
|
||||
* By default, Playwright looks for files matching the following glob pattern: `**\/*.@(spec|test).?(m)[jt]s?(x)`. This
|
||||
* means JavaScript or TypeScript files with `".test"` or `".spec"` suffix, for example
|
||||
* `login-screen.wrong-credentials.spec.ts`.
|
||||
*
|
||||
* Use [testConfig.testMatch](https://playwright.dev/docs/api/class-testconfig#test-config-test-match) to change this
|
||||
* option for all projects.
|
||||
|
|
|
|||
|
|
@ -153,14 +153,6 @@ test('should match tests well', async ({ runInlineTest }) => {
|
|||
import { test, expect } from '@playwright/test';
|
||||
test('works', () => {});
|
||||
`,
|
||||
'test.ts': `
|
||||
import { test, expect } from '@playwright/test';
|
||||
test('works', () => {});
|
||||
`,
|
||||
'spec.ts': `
|
||||
import { test, expect } from '@playwright/test';
|
||||
test('works', () => {});
|
||||
`,
|
||||
'strange.....spec.ts': `
|
||||
import { test, expect } from '@playwright/test';
|
||||
test('works', () => {});
|
||||
|
|
@ -184,7 +176,7 @@ test('should match tests well', async ({ runInlineTest }) => {
|
|||
});
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.passed).toBe(5);
|
||||
expect(result.passed).toBe(3);
|
||||
});
|
||||
|
||||
test('should load an mjs file', async ({ runInlineTest }) => {
|
||||
|
|
@ -690,14 +682,19 @@ test('should support dynamic import', async ({ runInlineTest, nodeVersion }) =>
|
|||
expect(result.exitCode).toBe(0);
|
||||
});
|
||||
|
||||
test('should allow test.extend.ts file', async ({ runInlineTest }) => {
|
||||
test('should allow test.extend.ts and test.ts files', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'test.extend.ts': `
|
||||
export { test, expect } from '@playwright/test';
|
||||
`,
|
||||
'test.ts': `
|
||||
export const helper = 42;
|
||||
`,
|
||||
'a.test.ts': `
|
||||
import { test, expect } from './test.extend';
|
||||
import { helper } from './test';
|
||||
test('pass1', async () => {
|
||||
expect(helper).toBe(42);
|
||||
});
|
||||
`,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue