Skip to content

chore(deps): update vitest monorepo to v3 (major) #7066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
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
1,444 changes: 528 additions & 916 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"@types/through2-map": "3.0.4",
"@types/write-file-atomic": "4.0.3",
"@types/ws": "8.18.1",
"@vitest/coverage-v8": "1.6.1",
"@vitest/coverage-v8": "3.1.1",
"@vitest/eslint-plugin": "^1.1.36",
"c8": "10.1.3",
"cheerio": "1.0.0",
Expand All @@ -216,7 +216,7 @@
"typescript": "5.7.3",
"typescript-eslint": "^8.26.0",
"verdaccio": "6.0.5",
"vitest": "1.6.1"
"vitest": "3.1.1"
},
"ava": {
"files": [
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/commands/build/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path, { join } from 'path'
import process from 'process'

import execa from 'execa'
import { describe, expect, test, type TaskContext, type TestContext } from 'vitest'
import { describe, expect, test, type TestContext } from 'vitest'

import { callCli } from '../../utils/call-cli.js'
import { cliPath } from '../../utils/cli-path.js'
Expand All @@ -22,7 +22,7 @@ const defaultEnvs = {
* - that its output contains `output`
*/
const runBuildCommand = async function (
t: TaskContext & TestContext,
t: TestContext,
cwd: string,
options: Partial<{
exitCode: number
Expand Down
30 changes: 16 additions & 14 deletions tests/integration/commands/dev/dev-forms-and-redirects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,20 +490,22 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {

await builder.build()

t.expect(() =>
withDevServer(
{ cwd: builder.directory },
async (server) => {
const [response1, response2] = await Promise.all([
fetch(`${server.url}/foo`).then((res) => res.text()),
fetch(`http://localhost:${userServerPort}`).then((res) => res.text()),
])
await t.expect(response1).toEqual('<html><h1>foo')
await t.expect(response2).toEqual('Hello world')
},
{ message: /Error: Something went wrong/ },
),
).rejects.toThrowError()
await t
.expect(() =>
withDevServer(
{ cwd: builder.directory },
async (server) => {
const [response1, response2] = await Promise.all([
fetch(`${server.url}/foo`).then((res) => res.text()),
fetch(`http://localhost:${userServerPort}`).then((res) => res.text()),
])
await t.expect(response1).toEqual('<html><h1>foo')
await t.expect(response2).toEqual('Hello world')
},
{ message: /Error: Something went wrong/ },
),
)
.rejects.toThrowError()
})
})
})
4 changes: 2 additions & 2 deletions tests/integration/commands/dev/dev-miscellaneous.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import execa, { ExecaError } from 'execa'
import getAvailablePort from 'get-port'
import jwt from 'jsonwebtoken'
import fetch from 'node-fetch'
import { type TestContext, type TaskContext, describe, test } from 'vitest'
import { type TestContext, describe, test } from 'vitest'
import type { HandlerEvent, HandlerContext } from '@netlify/functions'
import type { Context as EdgeHandlerContext } from '@netlify/edge-functions'

Expand Down Expand Up @@ -66,7 +66,7 @@ const validateRoleBasedRedirectsSite = async ({
builder: SiteBuilder
jwtRolePath?: string | undefined
jwtSecret?: string | undefined
t: TaskContext & TestContext
t: TestContext
}) => {
const [adminToken, editorToken] = await Promise.all([
getToken({ jwtSecret, jwtRolePath, roles: ['admin'] }),
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/commands/envelope/envelope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe.concurrent('command/envelope', () => {
await builder.build()

await withMockApi(routes, async ({ apiUrl }) => {
t.expect(callCli(['env:import', '.env'], getCLIOptions({ builder, apiUrl }))).rejects.toThrow()
await t.expect(callCli(['env:import', '.env'], getCLIOptions({ builder, apiUrl }))).rejects.toThrow()
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/commands/init/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { readFile } from 'node:fs/promises'
import cleanDeep from 'clean-deep'
import execa from 'execa'
import toml from 'toml'
import { describe, test, type TaskContext, type TestContext } from 'vitest'
import { describe, test, type TestContext } from 'vitest'

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

const assertNetlifyToml = async (
t: TaskContext & TestContext,
t: TestContext,
tomlDir: string,
{ command, functions, publish }: { command: string; functions: string; publish: string },
) => {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/commands/logs/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ describe('logs:deploy command', () => {
const setupCall = spyOn.mock.calls.find((args) => args[0] === 'open')
expect(setupCall).toBeDefined()

const openCallback = setupCall[1]
openCallback()
const openCallback = setupCall?.[1]
openCallback?.()

expect(spySend).toHaveBeenCalledOnce()
const call = spySend.mock.calls[0]
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/commands/logs/functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ describe('logs:function command', () => {
const setupCall = spyOn.mock.calls.find((args) => args[0] === 'open')
expect(setupCall).toBeDefined()

const openCallback = setupCall[1]
openCallback()
const openCallback = setupCall?.[1]
openCallback?.()

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

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

messageCallbackFunc(JSON.stringify(mockInfoData))
messageCallbackFunc(JSON.stringify(mockWarnData))
messageCallbackFunc?.(JSON.stringify(mockInfoData))
messageCallbackFunc?.(JSON.stringify(mockWarnData))

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

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

messageCallbackFunc(JSON.stringify(mockInfoData))
messageCallbackFunc(JSON.stringify(mockWarnData))
messageCallbackFunc?.(JSON.stringify(mockInfoData))
messageCallbackFunc?.(JSON.stringify(mockWarnData))

expect(spyLog).toHaveBeenCalledTimes(2)
})
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/utils/site-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import serializeJS from 'serialize-javascript'
import tempDirectory from 'temp-dir'
import tomlify from 'tomlify-j0.4'
import { v4 as uuidv4 } from 'uuid'
import type { TaskContext } from 'vitest'
import type { TestContext } from 'vitest'

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

Expand Down Expand Up @@ -333,7 +333,7 @@ export const createSiteBuilder = ({ siteName }: { siteName: string }) => {
* @param taskContext used to infer directory name from test name
*/
export async function withSiteBuilder<T>(
taskContext: TaskContext,
taskContext: TestContext,
testHandler: (builder: SiteBuilder) => Promise<T>,
): Promise<T> {
let builder: SiteBuilder | undefined
Expand Down
3 changes: 3 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export default defineConfig({
snapshotFormat: {
escapeString: true,
},
// Pin to vitest@1 behavior: https://vitest.dev/guide/migration.html#default-pool-is-forks.
// TODO(serhalp) Remove this and fix hanging `next-app-without-config` fixture on Windows.
pool: 'threads',
poolOptions: {
threads: {
singleThread: true,
Expand Down
Loading