MCPcopy
hub / github.com/rx-angular/rx-angular / mockConsole

Function mockConsole

libs/test-helpers/src/lib/utils/mock-console.ts:1–9  ·  view source on GitHub ↗
(methods?: ('log' | 'warn' | 'error')[])

Source from the content-addressed store, hash-verified

1export const mockConsole = (methods?: ('log' | 'warn' | 'error')[]) => {
2 if (methods) {
3 return methods.forEach((m) => jest.spyOn(console, m).mockImplementation());
4 }
5
6 jest.spyOn(console, 'log').mockImplementation();
7 jest.spyOn(console, 'warn').mockImplementation();
8 jest.spyOn(console, 'error').mockImplementation();
9};

Calls 1

forEachMethod · 0.80

Tested by

no test coverage detected