MCPcopy Create free account
hub / github.com/stenciljs/core / patchConsoleError

Function patchConsoleError

test/wdio/prerender-test/cmp.test.tsx:42–54  ·  view source on GitHub ↗

* This monkey-patches `window.console.error` in order to fail a test if that * function is called within a test. * * @returns a teardown function which ondoes the monkey-patch

()

Source from the content-addressed store, hash-verified

40 * @returns a teardown function which ondoes the monkey-patch
41 */
42function patchConsoleError() {
43 const orgConsoleError = window.console.error;
44
45 window.console.error = function (...args: any[]) {
46 orgConsoleError.apply(window, args);
47 window.console.info('console.error', args);
48 throw new Error('console.error was called, this is not allowed in a unit test run');
49 };
50
51 return () => {
52 window.console.error = orgConsoleError;
53 };
54}
55
56describe('prerender', () => {
57 let iframe: HTMLElement;

Callers 1

cmp.test.tsxFile · 0.85

Calls 1

infoMethod · 0.80

Tested by

no test coverage detected