Skip to content

Commit a1cb971

Browse files
authored
fix!: remove deprecated APIs (#8428)
1 parent e69d8f4 commit a1cb971

File tree

38 files changed

+146
-434
lines changed

38 files changed

+146
-434
lines changed

docs/guide/browser/config.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,19 +295,6 @@ export interface BrowserScript {
295295
}
296296
```
297297

298-
## browser.testerScripts
299-
300-
- **Type:** `BrowserScript[]`
301-
- **Default:** `[]`
302-
303-
::: danger DEPRECATED
304-
This API is deprecated an will be removed in Vitest 4. Please, use [`browser.testerHtmlPath`](#browser-testerhtmlpath) field instead.
305-
:::
306-
307-
Custom scripts that should be injected into the tester HTML before the tests environment is initiated. This is useful to inject polyfills required for Vitest browser implementation. It is recommended to use [`setupFiles`](#setupfiles) in almost all cases instead of this.
308-
309-
The script `src` and `content` will be processed by Vite plugins.
310-
311298
## browser.commands
312299

313300
- **Type:** `Record<string, BrowserCommand>`

docs/guide/migration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ Vitest 4.0 removes some deprecated APIs, including:
237237
- `environmentMatchGlobs` config option. Use [`projects`](/guide/projects) instead.
238238
- Reporter APIs `onCollected`, `onSpecsCollected`, `onPathsCollected`, `onTaskUpdate` and `onFinished`. See [`Reporters API`](/advanced/api/reporters) for new alternatives. These APIs were introduced in Vitest `v3.0.0`.
239239
- `deps.external`, `deps.inline`, `deps.fallbackCJS` config options. Use `server.deps.external`, `server.deps.inline`, or `server.deps.fallbackCJS` instead.
240+
- `browser.testerScripts` config option. Use [`browser.testerHtmlPath`](/guide/browser/config#browser-testerhtmlpath) instead.
240241

241242
This release also removes all deprecated types. This finally fixes an issue where Vitest accidentally pulled in `@types/node` (see [#5481](https://github.com/vitest-dev/vitest/issues/5481) and [#6141](https://github.com/vitest-dev/vitest/issues/6141)).
242243

packages/browser/src/node/commands/fs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { isFileServingAllowed } from 'vitest/node'
88
function assertFileAccess(path: string, project: TestProject) {
99
if (
1010
!isFileServingAllowed(path, project.vite)
11-
&& !isFileServingAllowed(path, project.vitest.server)
11+
&& !isFileServingAllowed(path, project.vitest.vite)
1212
) {
1313
throw new Error(
1414
`Access denied to "${path}". See Vite config documentation for "server.fs": https://vitejs.dev/config/server-options.html#server-fs-strict.`,

packages/browser/src/node/plugin.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,12 +460,6 @@ export default (parentServer: ParentBrowserProject, base = '/'): Plugin[] => {
460460
return
461461
}
462462

463-
if (!parentServer.testerScripts) {
464-
const testerScripts = await parentServer.formatScripts(
465-
parentServer.config.browser.testerScripts,
466-
)
467-
parentServer.testerScripts = testerScripts
468-
}
469463
const stateJs = typeof parentServer.stateJs === 'string'
470464
? parentServer.stateJs
471465
: await parentServer.stateJs
@@ -562,7 +556,6 @@ body {
562556
injectTo: 'head',
563557
} as const
564558
: null,
565-
...parentServer.testerScripts,
566559
...testerTags,
567560
].filter(s => s != null)
568561
},

packages/browser/src/node/projectParent.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { slash } from './utils'
2323

2424
export class ParentBrowserProject {
2525
public orchestratorScripts: string | undefined
26-
public testerScripts: HtmlTagDescriptor[] | undefined
2726

2827
public faviconUrl: string
2928
public prefixOrchestratorUrl: string

packages/runner/src/utils/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@ export {
1919
getTests,
2020
hasFailed,
2121
hasTests,
22-
isAtomTest,
2322
isTestCase,
2423
} from './tasks'

packages/runner/src/utils/tasks.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ import type { Arrayable } from '@vitest/utils'
22
import type { Suite, Task, Test } from '../types/tasks'
33
import { toArray } from '@vitest/utils'
44

5-
/**
6-
* @deprecated use `isTestCase` instead
7-
*/
8-
export function isAtomTest(s: Task): s is Test {
9-
return isTestCase(s)
10-
}
11-
125
export function isTestCase(s: Task): s is Test {
136
return s.type === 'test'
147
}

packages/ui/client/composables/explorer/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
TestTreeNode,
77
UITaskTreeNode,
88
} from '~/composables/explorer/types'
9-
import { isAtomTest } from '@vitest/runner/utils'
9+
import { isTestCase } from '@vitest/runner/utils'
1010
import { client } from '~/composables/client'
1111
import { explorerTree } from '~/composables/explorer/index'
1212
import { openedTreeItemsSet } from '~/composables/explorer/state'
@@ -117,7 +117,7 @@ export function createOrUpdateNodeTask(id: string) {
117117

118118
const task = client.state.idMap.get(id)
119119
// if it is not a test just return
120-
if (!task || !isAtomTest(task)) {
120+
if (!task || !isTestCase(task)) {
121121
return
122122
}
123123

@@ -148,7 +148,7 @@ export function createOrUpdateNode(
148148
taskNode.state = task.result?.state
149149
}
150150
else {
151-
if (isAtomTest(task)) {
151+
if (isTestCase(task)) {
152152
taskNode = {
153153
id: task.id,
154154
fileId: task.file.id,

packages/vitest/src/api/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function setup(ctx: Vitest, _server?: ViteDevServer): void {
2929

3030
const clients = new Map<WebSocket, WebSocketRPC>()
3131

32-
const server = _server || ctx.server
32+
const server = _server || ctx.vite
3333

3434
server.httpServer?.on('upgrade', (request: IncomingMessage, socket, head) => {
3535
if (!request.url) {

packages/vitest/src/node/ast-collect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export function createFailedFileTask(project: TestProject, filepath: string, err
197197
tasks: [],
198198
start: 0,
199199
end: 0,
200-
projectName: project.getName(),
200+
projectName: project.name,
201201
meta: {},
202202
pool: project.browser ? 'browser' : project.config.pool,
203203
file: null!,

0 commit comments

Comments
 (0)