Skip to content

Commit 85bee3a

Browse files
authored
chore: enhance test debugging and refactor build scripts (#101)
Add launch configuration for proper test debugging in VS Code Refactor package.json build scripts to simplify developer workflow
1 parent 1fb4df6 commit 85bee3a

File tree

8 files changed

+60
-221
lines changed

8 files changed

+60
-221
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"allowBranch": ["main"],
77
"conventionalCommits": true,
88
"createRelease": "github",
9-
"forcePublish": true,
9+
"forcePublish": false,
1010
"exact": true,
1111
"preid": "beta"
1212
}

package-lock.json

Lines changed: 13 additions & 191 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/vscode-plugin/.vscode/launch.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515
],
1616
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
1717
"preLaunchTask": "${defaultBuildTask}"
18+
},
19+
{
20+
"name": "Run Extension Tests",
21+
"type": "extensionHost",
22+
"request": "launch",
23+
"runtimeExecutable": "${execPath}",
24+
"args": [
25+
"--extensionDevelopmentPath=${workspaceFolder}",
26+
"--disable-extensions",
27+
"--extensionTestsPath=${workspaceFolder}/out/test/test-runner"
28+
],
29+
"outFiles": ["${workspaceFolder}/out/test/**/*.js"]
1830
}
1931
]
2032
}

packages/vscode-plugin/.vscode/tasks.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,6 @@
3737
"group": "watch",
3838
"reveal": "never"
3939
}
40-
},
41-
{
42-
"type": "npm",
43-
"script": "watch-tests",
44-
"problemMatcher": "$tsc-watch",
45-
"isBackground": true,
46-
"presentation": {
47-
"reveal": "never",
48-
"group": "watchers"
49-
},
50-
"group": "build"
51-
},
52-
{
53-
"label": "tasks: watch-tests",
54-
"dependsOn": ["npm: watch", "npm: watch-tests"],
55-
"problemMatcher": []
5640
}
5741
]
5842
}

packages/vscode-plugin/.vscodeignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ vsc-extension-quickstart.md
1515
../**
1616
../../**
1717
images/**
18-
!images/icon.png
18+
!images/icon.png
19+
tsconfig.tsbuildinfo

packages/vscode-plugin/package.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,14 @@
9292
}
9393
},
9494
"scripts": {
95-
"vscode:prepublish": "npm run build",
96-
"compile": "npm run check-types && npm run lint && node esbuild.js",
97-
"watch": "npm-run-all -p watch:*",
95+
"build": "node esbuild.js --production && tsc -b",
96+
"watch:tsc": "tsc -b -w",
9897
"watch:esbuild": "node esbuild.js --watch",
99-
"watch:tsc": "tsc --watch --noEmit",
100-
"build": "npm run check-types && npm run lint && node esbuild.js --production",
101-
"build:tsc": "tsc",
102-
"clean": "rm -rf out",
103-
"compile-tests": "npm run clean && tsc --outDir out",
104-
"watch-tests": "npm run clean && tsc -w --outDir out",
105-
"pretest": "npm run compile-tests && npm run compile",
106-
"check-types": "tsc --noEmit",
98+
"clean": "rm -rf dist out \".vscode-test\"",
10799
"lint": "eslint src",
108100
"test": "vscode-test",
109101
"test:linux": "xvfb-run -a vscode-test",
102+
"pack": "vsce package",
110103
"deploy": "vsce publish --azure-credential",
111104
"postdeploy": "ovsx publish --pat $OVSX_TOKEN",
112105
"deploy:prerelease": "vsce publish --azure-credential --pre-release"
@@ -128,6 +121,7 @@
128121
"chai-as-promised": "^8.0.2",
129122
"esbuild": "^0.27.0",
130123
"eslint": "^9.37.0",
124+
"glob": "^10.5.0",
131125
"npm-run-all": "^4.1.5",
132126
"ovsx": "^0.10.6",
133127
"sinon": "^21.0.0",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as path from 'path';
2+
import { glob } from 'glob';
3+
import Mocha from 'mocha';
4+
5+
export async function run(): Promise<void> {
6+
const testsRoot = __dirname;
7+
8+
const mocha = new Mocha({
9+
ui: 'bdd',
10+
rootHooks: {
11+
beforeAll() {
12+
import('./setup.js');
13+
},
14+
},
15+
});
16+
17+
const testFiles = await glob('**/**.spec.js', { cwd: testsRoot });
18+
testFiles.forEach((file) => mocha.addFile(path.resolve(testsRoot, file)));
19+
20+
const failures = await new Promise<number>((resolve) => {
21+
mocha.run((failures) => resolve(failures));
22+
});
23+
24+
if (failures > 0) {
25+
throw new Error(`${failures} tests failed.`);
26+
}
27+
}

packages/vscode-plugin/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"module": "nodenext",
44
"target": "ES2022",
55
"lib": ["ES2022"],
6-
// "noEmit": true,
76
"sourceMap": true,
87
"rootDir": "src",
98
"strict": true,

0 commit comments

Comments
 (0)