How to use the istanbul-lib-hook.hookCreateScript function in istanbul-lib-hook

To help you get started, we’ve selected a few istanbul-lib-hook examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / istanbul-lib-hook / istanbul-lib-hook-tests.ts View on Github external
const matcher = (filename: string) => true;
const transformer = (code: string, options: { filename: string }) => 'foo';

hookRequire(matcher, transformer);
hookRequire(matcher, transformer, {});
hookRequire(matcher, transformer, { verbose: true });

const retVal = hookRequire(matcher, transformer, {
	extensions: ['.js'],
	postLoadHook: (filename: string) => {}
});
retVal();

hookCreateScript(matcher, transformer, {});
hookCreateScript(matcher, transformer, { verbose: true });

unhookCreateScript();

hookRunInThisContext(matcher, transformer, {});
hookRunInThisContext(matcher, transformer, { verbose: true });

unhookRunInThisContext();

unloadRequireCache(matcher);

hookRunInContext(matcher, transformer, {});
hookRunInContext(matcher, transformer, { verbose: true, coverageVariable: '__cov__' });

unhookRunInContext();