Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions apps/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,13 @@
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/glob": "^8.1.0",
"@types/mocha": "^10.0.10",
"@types/node": "^16.11.68",
"@types/vscode": "^1.77.0",
"@vscode/test-electron": "^2.5.2",
"esbuild": "^0.25.11",
"glob": "^8.1.0",
"mocha": "^10.8.2",
"glob": "^11.0.3",
"mocha": "^11.7.4",
"npm-run-all": "^4.1.5"
},
"dependencies": {
Expand Down
7 changes: 6 additions & 1 deletion apps/vscode-extension/src/test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ async function main() {
const extensionTestsPath = path.resolve(__dirname, "./suite/index");

// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath });
await runTests({
version: "1.77.0",
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: ["--disable-extensions"],
});
} catch (err) {
console.error("Failed to run tests");
process.exit(1);
Expand Down
51 changes: 21 additions & 30 deletions apps/vscode-extension/src/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,33 @@
import * as path from "path";
import Mocha from "mocha";
import glob from "glob";
import { glob } from "glob";

export function run(): Promise<void> {
export function run(
testsRoot: string,
cb: (error: unknown | null, failures?: number) => void
): void {
// Create the mocha test
const mocha = new Mocha({
ui: "tdd",
color: true,
});

const testsRoot = path.resolve(__dirname, "..");
glob("**/**.test.js", { cwd: testsRoot })
.then((files) => {
// Add files to the test suite
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

return new Promise((c, e) => {
glob(
"**/**.test.js",
{ cwd: testsRoot },
(err: Error | null, files: string[]) => {
if (err) {
return e(err);
}

// Add files to the test suite
files.forEach((f: string) => mocha.addFile(path.resolve(testsRoot, f)));

try {
// Run the mocha test
mocha.run((failures: number) => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
console.error(err);
e(err as Error);
}
try {
// Run the mocha test
mocha.run((failures) => {
cb(null, failures);
});
} catch (err) {
console.error(err);
cb(err);
}
);
});
})
.catch((err) => {
return cb(err);
});
}
Loading