Skip to content

Commit 56e7654

Browse files
authored
Unit test framework and some bug fixes (#29)
This PR adds: 1. A mock framework for all VS Code types to allow easy and fast testing. 2. Adds a sample test 3. Fixes few bugs found while setting up the framework
1 parent 0c92933 commit 56e7654

28 files changed

+6841
-239
lines changed

.vscode/launch.json

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,45 @@
33
// Hover to view descriptions of existing attributes.
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
{
6-
"version": "0.2.0",
7-
"configurations": [
8-
{
9-
"name": "Run Extension",
10-
"type": "extensionHost",
11-
"request": "launch",
12-
"args": [
13-
"--extensionDevelopmentPath=${workspaceFolder}"
14-
],
15-
"outFiles": [
16-
"${workspaceFolder}/dist/**/*.js"
17-
],
18-
"preLaunchTask": "${defaultBuildTask}"
19-
},
20-
{
21-
"name": "Extension Tests",
22-
"type": "extensionHost",
23-
"request": "launch",
24-
"args": [
25-
"--extensionDevelopmentPath=${workspaceFolder}",
26-
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
27-
],
28-
"outFiles": [
29-
"${workspaceFolder}/out/**/*.js",
30-
"${workspaceFolder}/dist/**/*.js"
31-
],
32-
"preLaunchTask": "tasks: watch-tests"
33-
}
34-
]
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Run Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
13+
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
14+
"preLaunchTask": "${defaultBuildTask}"
15+
},
16+
{
17+
"args": [
18+
"-u=tdd",
19+
"--timeout=999999",
20+
"--colors",
21+
"--recursive",
22+
//"--grep", "<suite name>",
23+
"--require=out/test/unittests.js",
24+
"./out/test/**/*.unit.test.js"
25+
],
26+
"internalConsoleOptions": "openOnSessionStart",
27+
"name": "Unit Tests",
28+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
29+
"request": "launch",
30+
"skipFiles": ["<node_internals>/**"],
31+
"outFiles": ["${workspaceFolder}/out/**/*.js", "!${workspaceFolder}/**/node_modules**/*"],
32+
"type": "node",
33+
"preLaunchTask": "tasks: watch-tests"
34+
},
35+
{
36+
"name": "Extension Tests",
37+
"type": "extensionHost",
38+
"request": "launch",
39+
"args": [
40+
"--extensionDevelopmentPath=${workspaceFolder}",
41+
"--extensionTestsPath=${workspaceFolder}/out/test/"
42+
],
43+
"outFiles": ["${workspaceFolder}/out/**/*.js", "${workspaceFolder}/dist/**/*.js"],
44+
"preLaunchTask": "tasks: watch-tests"
45+
}
46+
]
3547
}

.vscode/tasks.json

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,37 @@
11
// See https://go.microsoft.com/fwlink/?LinkId=733558
22
// for the documentation about the tasks.json format
33
{
4-
"version": "2.0.0",
5-
"tasks": [
6-
{
7-
"type": "npm",
8-
"script": "watch",
9-
"problemMatcher": "$ts-webpack-watch",
10-
"isBackground": true,
11-
"presentation": {
12-
"reveal": "never",
13-
"group": "watchers"
14-
},
15-
"group": {
16-
"kind": "build",
17-
"isDefault": true
18-
}
19-
},
20-
{
21-
"type": "npm",
22-
"script": "watch-tests",
23-
"problemMatcher": "$tsc-watch",
24-
"isBackground": true,
25-
"presentation": {
26-
"reveal": "never",
27-
"group": "watchers"
28-
},
29-
"group": "build"
30-
},
31-
{
32-
"label": "tasks: watch-tests",
33-
"dependsOn": [
34-
"npm: watch",
35-
"npm: watch-tests"
36-
],
37-
"problemMatcher": []
38-
}
39-
]
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "watch",
9+
"problemMatcher": "$ts-webpack-watch",
10+
"isBackground": true,
11+
"presentation": {
12+
"reveal": "never",
13+
"group": "watchers"
14+
},
15+
"group": {
16+
"kind": "build",
17+
"isDefault": true
18+
}
19+
},
20+
{
21+
"type": "npm",
22+
"script": "watch-tests",
23+
"problemMatcher": "$tsc-watch",
24+
"isBackground": true,
25+
"presentation": {
26+
"reveal": "never",
27+
"group": "watchers"
28+
},
29+
"group": "build"
30+
},
31+
{
32+
"label": "tasks: watch-tests",
33+
"dependsOn": ["npm: watch", "npm: watch-tests"],
34+
"problemMatcher": []
35+
}
36+
]
4037
}

0 commit comments

Comments
 (0)