Skip to content

Commit 9bca90a

Browse files
authored
Enable Mocha Test Explorer Integration (#4518)
* Initial Mocha Test Explorer Implementation * update test runner to be compatible with both test runner and launch configs * Better logging * Reduce verbosity of binary module build * Test reporting and color in devops * Cast all catch variables as unknown * Configure slow timers to reduce noise for typically slow tests * Consolidate Launch and Attach! Figured it out * Remove debugging lines * Remove compound task no longer needed * Remove extraneous bracket
1 parent 4d71946 commit 9bca90a

15 files changed

+578
-335
lines changed

.mocharc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"color": true,
3+
"enable-source-maps": true,
4+
"extensions": [
5+
".js",
6+
".jsx"
7+
],
8+
"require": "source-map-support/register",
9+
"timeout": 10000,
10+
"spec": "out/test/**/*.test.js"
11+
}

.vscode/launch.json

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
// NOTE: These are not in the code-workspace file because StartDebugging cannot current resolve configs stored there so they have to be here for the Mocha Test Explorer feature.
5+
// Ref: https://github.com/microsoft/vscode/issues/150663
6+
{
7+
"name": "Launch Extension",
8+
"type": "extensionHost",
9+
"request": "launch",
10+
"runtimeExecutable": "${execPath}",
11+
"args": [
12+
"--extensionDevelopmentPath=${workspaceFolder}"
13+
],
14+
"env": {
15+
"__TEST_WORKSPACE_PATH": "${workspaceFolder}/examples",
16+
},
17+
"sourceMaps": true,
18+
// This speeds up source map detection and makes smartStep work correctly
19+
"outFiles": [
20+
"${workspaceFolder}/out/**/*.js",
21+
"!**/node_modules/**",
22+
"!**/.vscode-test/**"
23+
],
24+
"skipFiles": [
25+
"<node_internals>/**",
26+
"**/node_modules/**",
27+
"**/.vscode-test/**"
28+
],
29+
"presentation": {
30+
"hidden": false,
31+
"group": "test",
32+
"order": 2
33+
}
34+
},
35+
{
36+
// Runs the extension in an empty temp profile that is automatically cleaned up after use
37+
// Undocumented: https://github.com/microsoft/vscode-docs/issues/6220
38+
"name": "Launch Extension - Temp Profile",
39+
"type": "extensionHost",
40+
"request": "launch",
41+
"runtimeExecutable": "${execPath}",
42+
"args": [
43+
"--profile-temp",
44+
"--extensionDevelopmentPath=${workspaceFolder}",
45+
"${workspaceFolder}/examples"
46+
],
47+
"sourceMaps": true,
48+
// This speeds up source map detection and makes smartStep work correctly
49+
"outFiles": [
50+
"${workspaceFolder}/out/**/*.js",
51+
"!**/node_modules/**",
52+
"!**/.vscode-test/**"
53+
],
54+
"skipFiles": [
55+
"<node_internals>/**",
56+
"**/node_modules/**",
57+
"**/.vscode-test/**"
58+
],
59+
"presentation": {
60+
"hidden": false,
61+
"group": "test",
62+
"order": 2
63+
}
64+
},
65+
{
66+
// Runs the extension in an isolated but persistent profile separate from the user settings
67+
// Undocumented: https://github.com/microsoft/vscode-docs/issues/6220
68+
"name": "Launch Extension - Isolated Profile",
69+
"type": "extensionHost",
70+
"request": "launch",
71+
"runtimeExecutable": "${execPath}",
72+
"args": [
73+
"--profile=debug",
74+
"--extensionDevelopmentPath=${workspaceFolder}",
75+
"${workspaceFolder}/examples"
76+
],
77+
"sourceMaps": true,
78+
// This speeds up source map detection and makes smartStep work correctly
79+
"outFiles": [
80+
"${workspaceFolder}/out/**/*.js",
81+
"!**/node_modules/**",
82+
"!**/.vscode-test/**"
83+
],
84+
"skipFiles": [
85+
"<node_internals>/**",
86+
"**/node_modules/**",
87+
"**/.vscode-test/**"
88+
],
89+
"presentation": {
90+
"hidden": false,
91+
"group": "test",
92+
"order": 2
93+
}
94+
},
95+
{
96+
"name": "Test Extension",
97+
"type": "node",
98+
"request": "launch",
99+
"program": "${workspaceFolder}/out/test/runTests.js",
100+
"cascadeTerminateToConfigurations": [
101+
"ExtensionTests",
102+
],
103+
// This speeds up source map detection and makes smartStep work correctly
104+
"outFiles": [
105+
"${workspaceFolder}/out/**/*.js",
106+
"!**/node_modules/**",
107+
"!**/.vscode-test/**"
108+
],
109+
"skipFiles": [
110+
"<node_internals>/**",
111+
"**/node_modules/**",
112+
"**/.vscode-test/**"
113+
],
114+
"attachSimplePort": 59229, // THe default is 9229 but we want to avoid conflicts because we will have two vscode instances running.
115+
"env": {
116+
"__TEST_DEBUG_INSPECT_PORT": "59229" // Needs to match attachSimplePort
117+
},
118+
"presentation": {
119+
"hidden": false,
120+
},
121+
"internalConsoleOptions": "neverOpen",
122+
"console": "integratedTerminal",
123+
"autoAttachChildProcesses": false,
124+
"preLaunchTask": "test-watch"
125+
}
126+
]
127+
}

.vscode/tasks.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "test-watch",
6+
"icon": {
7+
"color": "terminal.ansiCyan",
8+
"id": "sync"
9+
},
10+
"type": "npm",
11+
"script": "build-test-watch",
12+
"group": "test",
13+
"problemMatcher": "$tsc-watch",
14+
"isBackground": true,
15+
"dependsOn": "build-watch" // We need to also build main.js extension for testing or it leads to sourcemap errors
16+
},
17+
{
18+
"label": "build-watch",
19+
"icon": {
20+
"color": "terminal.ansiCyan",
21+
"id": "sync"
22+
},
23+
"type": "npm",
24+
"script": "build-watch",
25+
"group": "build",
26+
"problemMatcher": "$esbuild-watch",
27+
"isBackground": true,
28+
}
29+
]
30+
}

0 commit comments

Comments
 (0)