Skip to content

Commit b60c7d3

Browse files
chore(deps): update vitest monorepo to v3 (#7066)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent d9e769c commit b60c7d3

11 files changed

+568
-951
lines changed

package-lock.json

+528-916
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
"@types/through2-map": "3.0.4",
195195
"@types/write-file-atomic": "4.0.3",
196196
"@types/ws": "8.18.1",
197-
"@vitest/coverage-v8": "1.6.1",
197+
"@vitest/coverage-v8": "3.1.1",
198198
"@vitest/eslint-plugin": "^1.1.36",
199199
"c8": "10.1.3",
200200
"cheerio": "1.0.0",
@@ -216,7 +216,7 @@
216216
"typescript": "5.7.3",
217217
"typescript-eslint": "^8.26.0",
218218
"verdaccio": "6.0.5",
219-
"vitest": "1.6.1"
219+
"vitest": "3.1.1"
220220
},
221221
"ava": {
222222
"files": [

tests/integration/commands/build/build.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path, { join } from 'path'
22
import process from 'process'
33

44
import execa from 'execa'
5-
import { describe, expect, test, type TaskContext, type TestContext } from 'vitest'
5+
import { describe, expect, test, type TestContext } from 'vitest'
66

77
import { callCli } from '../../utils/call-cli.js'
88
import { cliPath } from '../../utils/cli-path.js'
@@ -22,7 +22,7 @@ const defaultEnvs = {
2222
* - that its output contains `output`
2323
*/
2424
const runBuildCommand = async function (
25-
t: TaskContext & TestContext,
25+
t: TestContext,
2626
cwd: string,
2727
options: Partial<{
2828
exitCode: number

tests/integration/commands/dev/dev-forms-and-redirects.test.js

+16-14
Original file line numberDiff line numberDiff line change
@@ -490,20 +490,22 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
490490

491491
await builder.build()
492492

493-
t.expect(() =>
494-
withDevServer(
495-
{ cwd: builder.directory },
496-
async (server) => {
497-
const [response1, response2] = await Promise.all([
498-
fetch(`${server.url}/foo`).then((res) => res.text()),
499-
fetch(`http://localhost:${userServerPort}`).then((res) => res.text()),
500-
])
501-
await t.expect(response1).toEqual('<html><h1>foo')
502-
await t.expect(response2).toEqual('Hello world')
503-
},
504-
{ message: /Error: Something went wrong/ },
505-
),
506-
).rejects.toThrowError()
493+
await t
494+
.expect(() =>
495+
withDevServer(
496+
{ cwd: builder.directory },
497+
async (server) => {
498+
const [response1, response2] = await Promise.all([
499+
fetch(`${server.url}/foo`).then((res) => res.text()),
500+
fetch(`http://localhost:${userServerPort}`).then((res) => res.text()),
501+
])
502+
await t.expect(response1).toEqual('<html><h1>foo')
503+
await t.expect(response2).toEqual('Hello world')
504+
},
505+
{ message: /Error: Something went wrong/ },
506+
),
507+
)
508+
.rejects.toThrowError()
507509
})
508510
})
509511
})

tests/integration/commands/dev/dev-miscellaneous.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import execa, { ExecaError } from 'execa'
99
import getAvailablePort from 'get-port'
1010
import jwt from 'jsonwebtoken'
1111
import fetch from 'node-fetch'
12-
import { type TestContext, type TaskContext, describe, test } from 'vitest'
12+
import { type TestContext, describe, test } from 'vitest'
1313
import type { HandlerEvent, HandlerContext } from '@netlify/functions'
1414
import type { Context as EdgeHandlerContext } from '@netlify/edge-functions'
1515

@@ -66,7 +66,7 @@ const validateRoleBasedRedirectsSite = async ({
6666
builder: SiteBuilder
6767
jwtRolePath?: string | undefined
6868
jwtSecret?: string | undefined
69-
t: TaskContext & TestContext
69+
t: TestContext
7070
}) => {
7171
const [adminToken, editorToken] = await Promise.all([
7272
getToken({ jwtSecret, jwtRolePath, roles: ['admin'] }),

tests/integration/commands/envelope/envelope.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe.concurrent('command/envelope', () => {
113113
await builder.build()
114114

115115
await withMockApi(routes, async ({ apiUrl }) => {
116-
t.expect(callCli(['env:import', '.env'], getCLIOptions({ builder, apiUrl }))).rejects.toThrow()
116+
await t.expect(callCli(['env:import', '.env'], getCLIOptions({ builder, apiUrl }))).rejects.toThrow()
117117
})
118118
})
119119
})

tests/integration/commands/init/init.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { readFile } from 'node:fs/promises'
44
import cleanDeep from 'clean-deep'
55
import execa from 'execa'
66
import toml from 'toml'
7-
import { describe, test, type TaskContext, type TestContext } from 'vitest'
7+
import { describe, test, type TestContext } from 'vitest'
88

99
import { cliPath } from '../../utils/cli-path.js'
1010
import { CONFIRM, DOWN, answerWithValue, handleQuestions } from '../../utils/handle-questions.js'
@@ -14,7 +14,7 @@ import { withSiteBuilder } from '../../utils/site-builder.js'
1414
const defaultFunctionsDirectory = 'netlify/functions'
1515

1616
const assertNetlifyToml = async (
17-
t: TaskContext & TestContext,
17+
t: TestContext,
1818
tomlDir: string,
1919
{ command, functions, publish }: { command: string; functions: string; publish: string },
2020
) => {

tests/integration/commands/logs/build.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ describe('logs:deploy command', () => {
109109
const setupCall = spyOn.mock.calls.find((args) => args[0] === 'open')
110110
expect(setupCall).toBeDefined()
111111

112-
const openCallback = setupCall[1]
113-
openCallback()
112+
const openCallback = setupCall?.[1]
113+
openCallback?.()
114114

115115
expect(spySend).toHaveBeenCalledOnce()
116116
const call = spySend.mock.calls[0]

tests/integration/commands/logs/functions.test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ describe('logs:function command', () => {
124124
const setupCall = spyOn.mock.calls.find((args) => args[0] === 'open')
125125
expect(setupCall).toBeDefined()
126126

127-
const openCallback = setupCall[1]
128-
openCallback()
127+
const openCallback = setupCall?.[1]
128+
openCallback?.()
129129

130130
expect(spySend).toHaveBeenCalledOnce()
131131
const call = spySend.mock.calls[0]
@@ -154,7 +154,7 @@ describe('logs:function command', () => {
154154

155155
await program.parseAsync(['', '', 'logs:function', '--level', 'info'])
156156
const messageCallback = spyOn.mock.calls.find((args) => args[0] === 'message')
157-
const messageCallbackFunc = messageCallback[1]
157+
const messageCallbackFunc = messageCallback?.[1]
158158
const mockInfoData = {
159159
level: LOG_LEVELS.INFO,
160160
message: 'Hello World',
@@ -164,8 +164,8 @@ describe('logs:function command', () => {
164164
message: 'There was a warning',
165165
}
166166

167-
messageCallbackFunc(JSON.stringify(mockInfoData))
168-
messageCallbackFunc(JSON.stringify(mockWarnData))
167+
messageCallbackFunc?.(JSON.stringify(mockInfoData))
168+
messageCallbackFunc?.(JSON.stringify(mockWarnData))
169169

170170
expect(spyLog).toHaveBeenCalledTimes(1)
171171
})
@@ -186,7 +186,7 @@ describe('logs:function command', () => {
186186

187187
await program.parseAsync(['', '', 'logs:function'])
188188
const messageCallback = spyOn.mock.calls.find((args) => args[0] === 'message')
189-
const messageCallbackFunc = messageCallback[1]
189+
const messageCallbackFunc = messageCallback?.[1]
190190
const mockInfoData = {
191191
level: LOG_LEVELS.INFO,
192192
message: 'Hello World',
@@ -196,8 +196,8 @@ describe('logs:function command', () => {
196196
message: 'There was a warning',
197197
}
198198

199-
messageCallbackFunc(JSON.stringify(mockInfoData))
200-
messageCallbackFunc(JSON.stringify(mockWarnData))
199+
messageCallbackFunc?.(JSON.stringify(mockInfoData))
200+
messageCallbackFunc?.(JSON.stringify(mockWarnData))
201201

202202
expect(spyLog).toHaveBeenCalledTimes(2)
203203
})

tests/integration/utils/site-builder.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import serializeJS from 'serialize-javascript'
1313
import tempDirectory from 'temp-dir'
1414
import tomlify from 'tomlify-j0.4'
1515
import { v4 as uuidv4 } from 'uuid'
16-
import type { TaskContext } from 'vitest'
16+
import type { TestContext } from 'vitest'
1717

1818
const ensureDir = (directory: string) => mkdir(directory, { recursive: true })
1919

@@ -333,7 +333,7 @@ export const createSiteBuilder = ({ siteName }: { siteName: string }) => {
333333
* @param taskContext used to infer directory name from test name
334334
*/
335335
export async function withSiteBuilder<T>(
336-
taskContext: TaskContext,
336+
taskContext: TestContext,
337337
testHandler: (builder: SiteBuilder) => Promise<T>,
338338
): Promise<T> {
339339
let builder: SiteBuilder | undefined

vitest.config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export default defineConfig({
2121
snapshotFormat: {
2222
escapeString: true,
2323
},
24+
// Pin to vitest@1 behavior: https://vitest.dev/guide/migration.html#default-pool-is-forks.
25+
// TODO(serhalp) Remove this and fix hanging `next-app-without-config` fixture on Windows.
26+
pool: 'threads',
2427
poolOptions: {
2528
threads: {
2629
singleThread: true,

0 commit comments

Comments
 (0)