Skip to content
Open
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
4 changes: 4 additions & 0 deletions packages/cli/src/__tests__/database-url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ function noProject() {
}

beforeEach(() => {
// vitest 4's restoreAllMocks only restores vi.spyOn spies; it no longer
// clears the call history of vi.fn() mocks. Clear them explicitly so call
// counts don't bleed between tests.
vi.clearAllMocks()
originalEnv = process.env.DATABASE_URL
originalCi = process.env.CI
originalIsTty = process.stdin.isTTY
Expand Down
15 changes: 10 additions & 5 deletions packages/cli/src/__tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ const mockQuery = vi.fn()
const mockEnd = vi.fn()

vi.mock('pg', () => {
const Client = vi.fn(() => ({
connect: mockConnect,
query: mockQuery,
end: mockEnd,
}))
// vitest 4 invokes a mock's implementation as a real constructor when the
// mock is called with `new`. An arrow function cannot be a constructor, so
// the implementation must be a regular function.
const Client = vi.fn(function Client() {
return {
connect: mockConnect,
query: mockQuery,
end: mockEnd,
}
})
return { default: { Client } }
})

Expand Down
Loading
Loading