MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / setupCoverage

Function setupCoverage

src/test/coverage.node.ts:10–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8 * Rebuilds all other files with coverage instrumentations
9 */
10export async function setupCoverage() {
11 // In case of running integration tests like DS test with VS Code UI, we have no other way to add coverage.
12 // In such a case we need to instrument the code for coverage.
13 if (!process.env.VSC_JUPYTER_INSTRUMENT_CODE_FOR_COVERAGE) {
14 return;
15 }
16 const htmlReport = process.env.VSC_JUPYTER_INSTRUMENT_CODE_FOR_COVERAGE_HTML ? ['html'] : [];
17 const reports = htmlReport.concat(['text', 'text-summary', 'lcov']);
18 // Use dynamic import for nyc as it doesn't have type definitions
19 // @ts-expect-error - nyc doesn't have type definitions
20 const { default: NYC } = await import('nyc');
21 const nyc = new NYC({
22 cwd: path.join(EXTENSION_ROOT_DIR_FOR_TESTS),
23 extension: ['.ts'],
24 include: ['**/src/**/*.ts', '**/out/**/*.js'],
25 exclude: ['**/test/**', '.vscode-test/**', '**/ipywidgets/**', '**/node_modules/**'],
26 reporter: reports,
27 'report-dir': path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'coverage'),
28 all: true,
29 instrument: true,
30 hookRequire: true,
31 hookRunInContext: true,
32 hookRunInThisContext: true,
33 excludeNodeModules: true,
34 sourceMap: true
35 });
36
37 nyc.reset();
38 nyc.wrap();
39
40 return nyc as { writeCoverageFile: Function; report: () => Promise<void> };
41}

Callers 2

index.node.tsFile · 0.90
unittests.tsFile · 0.90

Calls 2

joinMethod · 0.80
resetMethod · 0.65

Tested by

no test coverage detected