Skip to content

Commit be11d37

Browse files
authored
fix!: remove deprecated environmentMatchGlobs and poolMatchGlobs (#8205)
1 parent bdd2e01 commit be11d37

File tree

18 files changed

+20
-252
lines changed

18 files changed

+20
-252
lines changed

docs/config/index.md

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -593,101 +593,6 @@ jsdom environment exposes `jsdom` global variable equal to the current [JSDOM](h
593593

594594
These options are passed down to `setup` method of current [`environment`](#environment). By default, you can configure only JSDOM options, if you are using it as your test environment.
595595

596-
### environmentMatchGlobs
597-
598-
- **Type:** `[string, EnvironmentName][]`
599-
- **Default:** `[]`
600-
601-
::: danger DEPRECATED
602-
This API was deprecated in Vitest 3. Use [projects](/guide/projects) to define different configurations instead.
603-
604-
```ts
605-
export default defineConfig({
606-
test: {
607-
environmentMatchGlobs: [ // [!code --]
608-
['./*.jsdom.test.ts', 'jsdom'], // [!code --]
609-
], // [!code --]
610-
projects: [ // [!code ++]
611-
{ // [!code ++]
612-
extends: true, // [!code ++]
613-
test: { // [!code ++]
614-
environment: 'jsdom', // [!code ++]
615-
}, // [!code ++]
616-
}, // [!code ++]
617-
], // [!code ++]
618-
},
619-
})
620-
```
621-
:::
622-
623-
Automatically assign environment based on globs. The first match will be used.
624-
625-
For example:
626-
627-
```ts
628-
import { defineConfig } from 'vitest/config'
629-
630-
export default defineConfig({
631-
test: {
632-
environmentMatchGlobs: [
633-
// all tests in tests/dom will run in jsdom
634-
['tests/dom/**', 'jsdom'],
635-
// all tests in tests/ with .edge.test.ts will run in edge-runtime
636-
['**\/*.edge.test.ts', 'edge-runtime'],
637-
// ...
638-
]
639-
}
640-
})
641-
```
642-
643-
### poolMatchGlobs {#poolmatchglobs}
644-
645-
- **Type:** `[string, 'threads' | 'forks' | 'vmThreads' | 'vmForks' | 'typescript'][]`
646-
- **Default:** `[]`
647-
648-
::: danger DEPRECATED
649-
This API was deprecated in Vitest 3. Use [projects](/guide/projects) to define different configurations instead:
650-
651-
```ts
652-
export default defineConfig({
653-
test: {
654-
poolMatchGlobs: [ // [!code --]
655-
['./*.threads.test.ts', 'threads'], // [!code --]
656-
], // [!code --]
657-
projects: [ // [!code ++]
658-
{ // [!code ++]
659-
test: { // [!code ++]
660-
extends: true, // [!code ++]
661-
pool: 'threads', // [!code ++]
662-
}, // [!code ++]
663-
}, // [!code ++]
664-
], // [!code ++]
665-
},
666-
})
667-
```
668-
:::
669-
670-
Automatically assign pool in which tests will run based on globs. The first match will be used.
671-
672-
For example:
673-
674-
```ts
675-
import { defineConfig } from 'vitest/config'
676-
677-
export default defineConfig({
678-
test: {
679-
poolMatchGlobs: [
680-
// all tests in "worker-specific" directory will run inside a worker as if you enabled `--pool=threads` for them,
681-
['**/tests/worker-specific/**', 'threads'],
682-
// run all tests in "browser" directory in an actual browser
683-
['**/tests/browser/**', 'browser'],
684-
// all other tests will run based on "browser.enabled" and "threads" options, if you didn't specify other globs
685-
// ...
686-
]
687-
}
688-
})
689-
```
690-
691596
### update<NonProjectOption />
692597

693598
- **Type:** `boolean`

docs/guide/environment.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ test('test', () => {
3939
})
4040
```
4141

42-
Or you can also set [`environmentMatchGlobs`](https://vitest.dev/config/#environmentmatchglobs) option specifying the environment based on the glob patterns.
43-
4442
## Custom Environment
4543

4644
You can create your own package to extend Vitest environment. To do so, create package with the name `vitest-environment-${name}` or specify a path to a valid JS/TS file. That package should export an object with the shape of `Environment`:

docs/guide/migration.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ See also new guides:
8585
- [Including and excluding files from coverage report](/guide/coverage.html#including-and-excluding-files-from-coverage-report) for examples
8686
- [Profiling Test Performance | Code coverage](/guide/profiling-test-performance.html#code-coverage) for tips about debugging coverage generation
8787

88+
### Deprecated APIs are Removed
89+
90+
Vitest 4.0 removes some deprecated APIs, including:
91+
92+
- `poolMatchGlobs` config option. Use [`projects`](/guide/projects) instead.
93+
- `environmentMatchGlobs` config option. Use [`projects`](/guide/projects) instead.
94+
8895
## Migrating to Vitest 3.0 {#vitest-3}
8996

9097
### Test Options as a Third Argument

packages/browser/src/node/plugin.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { basename, dirname, extname, resolve } from 'pathe'
1212
import sirv from 'sirv'
1313
import * as vite from 'vite'
1414
import { coverageConfigDefaults } from 'vitest/config'
15-
import { getFilePoolName, resolveApiServerConfig, resolveFsAllow, distDir as vitestDist } from 'vitest/node'
15+
import { resolveApiServerConfig, resolveFsAllow, distDir as vitestDist } from 'vitest/node'
1616
import { distRoot } from './constants'
1717
import { createOrchestratorMiddleware } from './middlewares/orchestratorMiddleware'
1818
import { createTesterMiddleware } from './middlewares/testerMiddleware'
@@ -165,10 +165,7 @@ export default (parentServer: ParentBrowserProject, base = '/'): Plugin[] => {
165165
// this plugin can be used in different projects, but all of them
166166
// have the same `include` pattern, so it doesn't matter which project we use
167167
const project = parentServer.project
168-
const { testFiles: allTestFiles } = await project.globTestFiles()
169-
const browserTestFiles = allTestFiles.filter(
170-
file => getFilePoolName(project, file) === 'browser',
171-
)
168+
const { testFiles: browserTestFiles } = await project.globTestFiles()
172169
const setupFiles = toArray(project.config.setupFiles)
173170

174171
// replace env values - cannot be reassign at runtime

packages/vitest/src/node/cli/cli-config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,6 @@ export const cliOptionsConfig: VitestCLIOptions = {
849849
includeSource: null,
850850
alias: null,
851851
env: null,
852-
environmentMatchGlobs: null,
853852
environmentOptions: null,
854853
unstubEnvs: null,
855854
related: null,
@@ -866,7 +865,6 @@ export const cliOptionsConfig: VitestCLIOptions = {
866865
chaiConfig: null,
867866
clearMocks: null,
868867
css: null,
869-
poolMatchGlobs: null,
870868
deps: null,
871869
name: null,
872870
snapshotEnvironment: null,

packages/vitest/src/node/config/resolveConfig.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -609,17 +609,6 @@ export function resolveConfig(
609609
if (!builtinPools.includes(resolved.pool as BuiltinPool)) {
610610
resolved.pool = resolvePath(resolved.pool, resolved.root)
611611
}
612-
if (resolved.poolMatchGlobs) {
613-
logger.deprecate('`poolMatchGlobs` is deprecated. Use `test.projects` to define different configurations instead.')
614-
}
615-
resolved.poolMatchGlobs = (resolved.poolMatchGlobs || []).map(
616-
([glob, pool]) => {
617-
if (!builtinPools.includes(pool as BuiltinPool)) {
618-
pool = resolvePath(pool, resolved.root)
619-
}
620-
return [glob, pool]
621-
},
622-
)
623612

624613
if (mode === 'benchmark') {
625614
resolved.benchmark = {
@@ -792,13 +781,6 @@ export function resolveConfig(
792781
...resolved.typecheck,
793782
}
794783

795-
if (resolved.environmentMatchGlobs) {
796-
logger.deprecate('"environmentMatchGlobs" is deprecated. Use `test.projects` to define different configurations instead.')
797-
}
798-
resolved.environmentMatchGlobs = (resolved.environmentMatchGlobs || []).map(
799-
i => [resolve(resolved.root, i[0]), i[1]],
800-
)
801-
802784
resolved.typecheck ??= {} as any
803785
resolved.typecheck.enabled ??= false
804786

packages/vitest/src/node/pool.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { TestProject } from './project'
44
import type { TestSpecification } from './spec'
55
import type { BuiltinPool, Pool } from './types/pool-options'
66
import { isatty } from 'node:tty'
7-
import pm from 'picomatch'
87
import { version as viteVersion } from 'vite'
98
import { isWindows } from '../utils/env'
109
import { createForksPool } from './pools/forks'
@@ -66,17 +65,7 @@ function getDefaultPoolName(project: TestProject): Pool {
6665
return project.config.pool
6766
}
6867

69-
export function getFilePoolName(project: TestProject, file: string): Pool {
70-
for (const [glob, pool] of project.config.poolMatchGlobs) {
71-
if ((pool as Pool) === 'browser') {
72-
throw new Error(
73-
'Since Vitest 0.31.0 "browser" pool is not supported in `poolMatchGlobs`. You can create a project to run some of your tests in browser in parallel. Read more: https://vitest.dev/guide/projects',
74-
)
75-
}
76-
if (pm.isMatch(file, glob, { cwd: project.config.root })) {
77-
return pool as Pool
78-
}
79-
}
68+
export function getFilePoolName(project: TestProject): Pool {
8069
return getDefaultPoolName(project)
8170
}
8271

packages/vitest/src/node/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export class TestProject {
157157
return new TestSpecification(
158158
this,
159159
moduleId,
160-
pool || getFilePoolName(this, moduleId),
160+
pool || getFilePoolName(this),
161161
locations,
162162
)
163163
}

packages/vitest/src/node/types/browser.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ type UnsupportedProperties =
6666
| 'api'
6767
| 'deps'
6868
| 'testTransformMode'
69-
| 'poolMatchGlobs'
70-
| 'environmentMatchGlobs'
7169
| 'environment'
7270
| 'environmentOptions'
7371
| 'server'

packages/vitest/src/node/types/config.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -332,24 +332,6 @@ export interface InlineConfig {
332332
*/
333333
environmentOptions?: EnvironmentOptions
334334

335-
/**
336-
* Automatically assign environment based on globs. The first match will be used.
337-
* This has effect only when running tests inside Node.js.
338-
*
339-
* Format: [glob, environment-name]
340-
*
341-
* @deprecated use [`projects`](https://vitest.dev/config/#projects) instead
342-
* @default []
343-
* @example [
344-
* // all tests in tests/dom will run in jsdom
345-
* ['tests/dom/**', 'jsdom'],
346-
* // all tests in tests/ with .edge.test.ts will run in edge-runtime
347-
* ['**\/*.edge.test.ts', 'edge-runtime'],
348-
* // ...
349-
* ]
350-
*/
351-
environmentMatchGlobs?: [string, VitestEnvironment][]
352-
353335
/**
354336
* Run tests in an isolated environment. This option has no effect on vmThreads pool.
355337
*
@@ -390,22 +372,6 @@ export interface InlineConfig {
390372
*/
391373
fileParallelism?: boolean
392374

393-
/**
394-
* Automatically assign pool based on globs. The first match will be used.
395-
*
396-
* Format: [glob, pool-name]
397-
*
398-
* @deprecated use [`projects`](https://vitest.dev/config/#projects) instead
399-
* @default []
400-
* @example [
401-
* // all tests in "forks" directory will run using "poolOptions.forks" API
402-
* ['tests/forks/**', 'forks'],
403-
* // all other tests will run based on "poolOptions.threads" option, if you didn't specify other globs
404-
* // ...
405-
* ]
406-
*/
407-
poolMatchGlobs?: [string, Exclude<Pool, 'browser'>][]
408-
409375
/**
410376
* Options for projects
411377
*/

0 commit comments

Comments
 (0)