The node module runs a local web server that serves VS Code in the browser including the extension under development. Additionally the extension tests are automatically run.
The node module provides a command line as well as an API.
VS Code for the Web will open on a virtual workspace (scheme vscode-test-web), backed by a file system provider that gets the file/folder data from the local disk. Changes to the file system are kept in memory and are not written back to disk.
Open VS Code in the Browser with external network access:
This allows the extension being tested to make network requests to external hosts.
Via API:
async function go() { try { // The folder containing the Extension Manifest package.json const extensionDevelopmentPath = path.resolve(__dirname, '../../../'); // The path to module with the test runner and tests const extensionTestsPath = path.resolve(__dirname, './suite/index'); // Start a web server that serves VSCode in a browser, run the tests await runTests({ browserType: 'chromium', extensionDevelopmentPath extensionTestsPath }); } catch (err) { console.error('Failed to run tests'); process.exit(1); }
CLI options:
Option
Argument Description
--browser
The browser to launch: chromium (default), firefox, webkit or none.
--browserOption
Command line argument to use when launching the browser instance. Argument can be provided multiple times.
--extensionDevelopmentPath
A path pointing to an extension under development to include.
--extensionTestsPath
A path to a test module to run.
--quality
insiders (default), or stable. Ignored when sourcesPath is provided.
--commit
commitHash The servion of the server to use. Defaults to latest build version of the given quality. Ignored when sourcesPath is provided.
--sourcesPath
If set, runs the server from VS Code sources located at the given path. Make sure the sources and extensions are compiled (npm run compile and npm run compile-web).
--headless
If set, hides the browser. Defaults to true when an extensionTestsPath is provided, otherwise false.
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.