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

Function run

src/test/testRunner.ts:49–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47}
48
49export async function run(): Promise<void> {
50 const testsRoot = path.join(__dirname, '..');
51 // Enable source map support.
52 // @ts-expect-error - source-map-support doesn't have type definitions
53 const sourceMapSupport = await import('source-map-support');
54 sourceMapSupport.default.install();
55
56 /**
57 * Waits until the Python Extension completes loading or a timeout.
58 * When running tests within VSC, we need to wait for the Python Extension to complete loading,
59 * this is where `initialize` comes in, we load the PVSC extension using VSC API, wait for it
60 * to complete.
61 * That's when we know out PVSC extension specific code is ready for testing.
62 * So, this code needs to run always for every test running in VS Code (what we call these `system test`) .
63 * @returns
64 */
65 function initializationScript() {
66 const ex = new Error('Failed to initialize Python Extension for tests after 3 minutes');
67 let timer: NodeJS.Timer | undefined;
68 const failed = new Promise((_, reject) => {
69 timer = setTimeout(() => reject(ex), MAX_EXTENSION_ACTIVATION_TIME);
70 });
71 const promise = Promise.race([initialize(), failed]);
72 promise.then(() => clearTimeout(timer! as any)).catch(() => clearTimeout(timer! as any));
73 return promise;
74 }
75 // Run the tests.
76 const files = await glob(`**/**.${testFilesGlob}.js`, { ignore: ['**/**.unit.test.js'], cwd: testsRoot });
77 files.forEach((file) => mocha.addFile(path.join(testsRoot, file)));
78
79 await new Promise<void>((resolve, reject) => {
80 initializationScript()
81 .then(() =>
82 mocha.run((failures) => (failures > 0 ? reject(new Error(`${failures} total failures`)) : resolve()))
83 )
84 .finally(() => {
85 stopJupyterServer().catch(noop);
86 })
87 .catch(reject);
88 });
89}

Callers

nothing calls this directly

Calls 7

stopJupyterServerFunction · 0.90
initializationScriptFunction · 0.85
joinMethod · 0.80
installMethod · 0.65
runMethod · 0.65
resolveFunction · 0.50
forEachMethod · 0.45

Tested by

no test coverage detected