()
| 156 | |
| 157 | export 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. |
no outgoing calls
no test coverage detected