MCPcopy
hub / github.com/prisma/prisma / vitestConsoleContext

Function vitestConsoleContext

packages/get-platform/src/test-utils/vitestContext.ts:158–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

156
157export const vitestConsoleContext =
158 <Ctx extends BaseContext>() =>
159 (c: Ctx) => {
160 const ctx = c as Ctx & ConsoleContext
161
162 beforeEach(() => {
163 ctx.mocked['console.error'] = vi.spyOn(console, 'error').mockImplementation(() => {})
164 ctx.mocked['console.log'] = vi.spyOn(console, 'log').mockImplementation(() => {})
165 ctx.mocked['console.info'] = vi.spyOn(console, 'info').mockImplementation(() => {})
166 ctx.mocked['console.warn'] = vi.spyOn(console, 'warn').mockImplementation(() => {})
167 })
168
169 afterEach(() => {
170 ctx.mocked['console.error'].mockRestore()
171 ctx.mocked['console.log'].mockRestore()
172 ctx.mocked['console.info'].mockRestore()
173 ctx.mocked['console.warn'].mockRestore()
174 })
175
176 return ctx
177 }
178
179/**
180 * Test context contributor. Mocks process.std(out|err).write with a Vitest spy before each test.

Callers 5

lintSchema.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected