Skip to content

Commit a2b6862

Browse files
authored
Merge pull request #984 from cipherstash/fix/cip-4107-vitest
fix(deps): bump vitest to 4.1.11
2 parents 04ecedd + 82c2867 commit a2b6862

13 files changed

Lines changed: 216 additions & 497 deletions

File tree

‎packages/bench/vitest.config.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ export default defineConfig({
1414
testTimeout: 300_000,
1515
hookTimeout: 300_000,
1616
pool: 'forks',
17-
poolOptions: {
18-
forks: { singleFork: true },
19-
},
2017
fileParallelism: false,
2118
},
2219
benchmark: {

‎packages/cli/src/__tests__/database-url.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ afterEach(() => {
7878
})
7979
// restoreAllMocks (not clearAllMocks) is what fully reverts spies on
8080
// global objects like `process.exit`. Without restoration the spy stays
81-
// attached and bleeds into later tests.
81+
// attached and bleeds into later tests. Since Vitest 4, restoreAllMocks only
82+
// reverts vi.spyOn spies; resetAllMocks is what clears the module-mock
83+
// vi.fn()s' calls and per-test implementations.
84+
vi.resetAllMocks()
8285
vi.restoreAllMocks()
8386
if (tmpDir && fs.existsSync(tmpDir)) {
8487
fs.rmSync(tmpDir, { recursive: true, force: true })

‎packages/cli/src/__tests__/installer.test.ts‎

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,24 @@ const mockEnd = vi.fn()
1010

1111
vi.mock('pg', () => ({
1212
default: {
13-
Client: vi.fn(() => ({
14-
connect: mockConnect,
15-
query: async (...args: unknown[]) => {
16-
const result = await mockQuery(...args)
17-
if (
18-
typeof args[0] === 'string' &&
19-
args[0].includes('pg_try_advisory') &&
20-
result?.rows?.[0]?.acquired === undefined
21-
) {
22-
return { ...result, rows: [{ acquired: true }] }
23-
}
24-
return result
25-
},
26-
end: mockEnd,
27-
})),
13+
// biome-ignore lint/complexity/useArrowFunction: Vitest 4 mocks called with `new` need a constructible (non-arrow) implementation.
14+
Client: vi.fn(function () {
15+
return {
16+
connect: mockConnect,
17+
query: async (...args: unknown[]) => {
18+
const result = await mockQuery(...args)
19+
if (
20+
typeof args[0] === 'string' &&
21+
args[0].includes('pg_try_advisory') &&
22+
result?.rows?.[0]?.acquired === undefined
23+
) {
24+
return { ...result, rows: [{ acquired: true }] }
25+
}
26+
return result
27+
},
28+
end: mockEnd,
29+
}
30+
}),
2831
},
2932
}))
3033

‎packages/cli/src/commands/auth/__tests__/region.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ afterEach(() => {
6868
process.env.CI = originalCi
6969
}
7070
setTty(originalIsTty)
71+
// Vitest 4: restoreAllMocks only reverts vi.spyOn spies; resetAllMocks
72+
// clears the module-mock vi.fn()s' calls and per-test implementations.
73+
vi.resetAllMocks()
7174
vi.restoreAllMocks()
7275
})
7376

‎packages/cli/src/commands/eql/__tests__/repair.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ const pgMock = vi.hoisted(() => ({
4848
}))
4949
vi.mock('pg', () => ({
5050
default: {
51-
Client: vi.fn((config: { connectionString?: string }) => {
51+
// biome-ignore lint/complexity/useArrowFunction: Vitest 4 mocks called with `new` need a constructible (non-arrow) implementation.
52+
Client: vi.fn(function (config: { connectionString?: string }) {
5253
pgMock.connectionStrings.push(config?.connectionString)
5354
return {
5455
connect: pgMock.connect,

‎packages/cli/src/commands/eql/__tests__/validate-command.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ const pgMock = vi.hoisted(() => ({
7474
}))
7575
vi.mock('pg', () => ({
7676
default: {
77-
Client: vi.fn((config: { connectionString?: string }) => {
77+
// biome-ignore lint/complexity/useArrowFunction: Vitest 4 mocks called with `new` need a constructible (non-arrow) implementation.
78+
Client: vi.fn(function (config: { connectionString?: string }) {
7879
pgMock.connectionStrings.push(config?.connectionString)
7980
return { connect: pgMock.connect, query: pgMock.query, end: pgMock.end }
8081
}),

‎packages/cli/src/commands/init/lib/__tests__/build-flow.integration.test.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ vi.mock('@clack/prompts', () => ({
1616
const queryMock = vi.fn()
1717
vi.mock('pg', () => ({
1818
default: {
19-
Client: vi.fn(() => ({
20-
connect: vi.fn(async () => {}),
21-
query: queryMock,
22-
end: vi.fn(async () => {}),
23-
})),
19+
// biome-ignore lint/complexity/useArrowFunction: Vitest 4 mocks called with `new` need a constructible (non-arrow) implementation.
20+
Client: vi.fn(function () {
21+
return {
22+
connect: vi.fn(async () => {}),
23+
query: queryMock,
24+
end: vi.fn(async () => {}),
25+
}
26+
}),
2427
},
2528
}))
2629

‎packages/cli/src/db/__tests__/client-wrap.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ const mockEnd = vi.fn()
55

66
vi.mock('pg', () => ({
77
default: {
8-
Client: vi.fn(() => {
8+
// biome-ignore lint/complexity/useArrowFunction: Vitest 4 mocks called with `new` need a constructible (non-arrow) implementation.
9+
Client: vi.fn(function () {
910
const client: Record<string, unknown> = {
1011
connect: (...args: unknown[]) => mockConnect(...args),
1112
end: mockEnd,

‎packages/cli/src/telemetry/__tests__/telemetry-lifecycle.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ describe('telemetry lifecycle (emitter + flush)', () => {
3838
beforeEach(() => {
3939
h.capture.mockReset()
4040
h.shutdown.mockReset().mockResolvedValue(undefined)
41-
h.PostHog.mockReset().mockImplementation(() => ({
42-
capture: h.capture,
43-
shutdown: h.shutdown,
44-
}))
41+
// biome-ignore lint/complexity/useArrowFunction: Vitest 4 mocks called with `new` need a constructible (non-arrow) implementation.
42+
h.PostHog.mockReset().mockImplementation(function () {
43+
return { capture: h.capture, shutdown: h.shutdown }
44+
})
4545
h.writeState.mockReset()
4646
h.state.value = { ...ENABLED }
4747
// Enabled by default; neutralize every gate so status is { enabled: true }.

‎packages/cli/vitest.config.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ export default defineConfig({
3333
test: {
3434
name: 'live',
3535
include: ['src/**/*.live.test.ts'],
36-
poolOptions: { forks: { singleFork: true } },
36+
// Vitest 4 removed `poolOptions.forks.singleFork`; running one file
37+
// at a time is what serialises the live suites.
38+
fileParallelism: false,
3739
},
3840
},
3941
],

0 commit comments

Comments
 (0)