-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathrunTests.mjs
68 lines (61 loc) · 2.25 KB
/
runTests.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// @ts-check
// Adapted from the sample at
// https://github.com/microsoft/vscode-test-web/blob/3f0f858ab15cb65ef3c19564b0f5a6910ea9414e/sample/src/web/test/runTest.ts
//
// This script is run using Node.js in the dev environment. It will
// download the latest Insiders build of VS Code for the Web and launch
// it in a headless instance of Chromium to run the integration test suite.
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { runTests } from "@vscode/test-web";
const thisDir = dirname(fileURLToPath(import.meta.url));
// The folder containing the Extension Manifest package.json
const extensionDevelopmentPath = join(thisDir, "..");
const attachArgName = "--waitForDebugger=";
const waitForDebugger = process.argv.find((arg) =>
arg.startsWith(attachArgName),
);
const verboseArgName = "--verbose";
/**
* This controls the VS Code and test web server logging level.
* Q# extension logs are usually more relevant for debugging tests.
* To control the Q# extension log level see: suites/extensionUtils.ts
*/
const verbose = process.argv.includes(verboseArgName);
try {
// Language service tests
await runSuite(
join(thisDir, "out", "language-service", "index"),
join(thisDir, "suites", "language-service", "test-workspace"),
);
// Debugger tests
await runSuite(
join(thisDir, "out", "debugger", "index"),
join(thisDir, "suites", "debugger", "test-workspace"),
);
} catch (err) {
console.error("Failed to run tests", err);
process.exit(1);
}
/**
* @param {string} extensionTestsPath - The path to module with the test runner and tests
* @param {string} workspacePath - The path to the workspace to be opened in VS Code
*/
async function runSuite(extensionTestsPath, workspacePath) {
// Start a web server that serves VS Code in a browser, run the tests
await runTests({
headless: true, // pass false to see VS Code UI
browserType: "chromium",
extensionDevelopmentPath,
extensionTestsPath,
folderPath: workspacePath,
quality: "stable",
printServerLog: verbose,
verbose,
waitForDebugger: waitForDebugger
? Number(waitForDebugger.slice(attachArgName.length))
: undefined,
});
}