()
| 164 | * @returns {Promise<void>} |
| 165 | */ |
| 166 | export async function run(): Promise<void> { |
| 167 | // Enable gc during tests |
| 168 | v8.setFlagsFromString('--expose_gc'); |
| 169 | const options = await configure(); |
| 170 | const mocha = new Mocha(options); |
| 171 | const testsRoot = path.join(__dirname, '..'); |
| 172 | // Enable source map support. |
| 173 | // Use dynamic import for source-map-support as it doesn't have type definitions |
| 174 | // @ts-expect-error - source-map-support doesn't have type definitions |
| 175 | const sourceMapSupport = await import('source-map-support'); |
| 176 | sourceMapSupport.default.install(); |
| 177 | |
| 178 | const ignoreGlob: string[] = []; |
| 179 | switch (options.testFilesSuffix.toLowerCase()) { |
| 180 | case 'native.vscode.test': { |
| 181 | break; |
| 182 | } |
| 183 | case 'vscode.test*': { |
| 184 | ignoreGlob.push('**/**.native.vscode.test*.js'); |
| 185 | break; |
| 186 | } |
| 187 | case '.test*': { |
| 188 | ignoreGlob.push('**/**.vscode.test*.js'); |
| 189 | break; |
| 190 | } |
| 191 | default: |
| 192 | break; |
| 193 | } |
| 194 | // If we have mulitple patterns, then turn into regex from `a,b,c` to `(a|b|c)` |
| 195 | const pattern = options.testFilesSuffix.includes(',') |
| 196 | ? `(${options.testFilesSuffix.split(',').join('|')})` |
| 197 | : options.testFilesSuffix; |
| 198 | const testFiles = await glob(`**/*${pattern}.js`, { |
| 199 | ignore: ['**/**.unit.test.js'].concat(ignoreGlob), |
| 200 | cwd: testsRoot |
| 201 | }); |
| 202 | |
| 203 | // Setup test files that need to be run. |
| 204 | testFiles.forEach((file) => mocha.addFile(path.join(testsRoot, file))); |
| 205 | |
| 206 | // for performance tests, extension activation is part of the test run |
| 207 | if (!IS_PERF_TEST()) { |
| 208 | await activateExtensionScript(); |
| 209 | } |
| 210 | |
| 211 | try { |
| 212 | // Run the tests. |
| 213 | await new Promise<void>((resolve, reject) => { |
| 214 | mocha.run((failures) => { |
| 215 | if (failures > 0) { |
| 216 | return reject(new Error(`${failures} total failures`)); |
| 217 | } |
| 218 | resolve(); |
| 219 | }); |
| 220 | }); |
| 221 | } finally { |
| 222 | stopJupyterServer().catch(noop); |
| 223 | const nyc = await nycPromise; |
nothing calls this directly
no test coverage detected