Skip to content

Commit ab0e14d

Browse files
authored
Speed up running of unit tests locally (with an optional flag) (microsoft#8565)
* Add ability to ignore bootstrap code from tests * Add debug config
1 parent d762b0e commit ab0e14d

3 files changed

Lines changed: 35 additions & 5 deletions

File tree

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,29 @@
158158
"preLaunchTask": "Compile",
159159
"skipFiles": ["<node_internals>/**"]
160160
},
161+
{
162+
"name": "Unit Tests (fast, without VS Code and without react/monaco, *.unit.test.ts)",
163+
"type": "node",
164+
"request": "launch",
165+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
166+
"stopOnEntry": false,
167+
"sourceMaps": true,
168+
"args": [
169+
"./out/test/**/*.unit.test.js",
170+
"--require=out/test/unittests.js",
171+
"--ui=tdd",
172+
"--recursive",
173+
"--colors",
174+
//"--grep", "<suite name>",
175+
"--timeout=300000",
176+
"--fast"
177+
],
178+
"outFiles": [
179+
"${workspaceFolder}/out/**/*.js"
180+
],
181+
"preLaunchTask": "Compile",
182+
"skipFiles": ["<node_internals>/**"]
183+
},
161184
{
162185
"name": "Functional Tests (without VS Code, *.functional.test.ts)",
163186
"type": "node",

news/3 Code Health/8564.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve startup times of unit tests by optionally ignoring some bootstrapping required for `monaco` and `react` tests.

src/test/unittests.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,16 @@ const Module = require('module');
5757
};
5858
})();
5959

60-
// nteract/transforms-full expects to run in the browser so we have to fake
61-
// parts of the browser here.
62-
setUpDomEnvironment();
60+
// Setting up DOM env and transpile is required for the react & monaco related tests.
61+
// However this takes around 40s to setup on Mac, hence slowing down testing/development.
62+
// Allowing ability to disable this (faster local development & testing, saving minutes).
63+
if (process.argv.indexOf('--fast') === -1) {
64+
// nteract/transforms-full expects to run in the browser so we have to fake
65+
// parts of the browser here.
66+
setUpDomEnvironment();
67+
68+
// Also have to setup babel to get the monaco editor to work.
69+
setupTranspile();
70+
}
6371

64-
// Also have to setup babel to get the monaco editor to work.
65-
setupTranspile();
6672
initialize();

0 commit comments

Comments
 (0)