MCPcopy
hub / github.com/prisma/prisma / jestConsoleContext

Function jestConsoleContext

packages/get-platform/src/test-utils/jestContext.ts:160–179  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 12

rpc.test.tsFile · 0.90
createDefaultTestContextFunction · 0.90
preinstall.test.tsFile · 0.90
Init.vitest.tsFile · 0.90
config.test.tsFile · 0.90
CLI.test.tsFile · 0.90
Version.test.tsFile · 0.90
Generate.test.tsFile · 0.90
DebugInfo.test.tsFile · 0.90
Format.test.tsFile · 0.90
Validate.test.tsFile · 0.90

Calls

no outgoing calls

Tested by 1

createDefaultTestContextFunction · 0.72