

This is easier to set up (because you don't need to write a launcher script), but requires that your entire workspace and large If you do so, your tests will also be run in this environment automatically. To move your workspace to the remote environment. There are also example projects containing well-documented launcher scripts for running your testsĪlternatively, you can use VS Code Remote Development

Package, which also contains utility functions for writing your launcher script. To load and run the tests in the remote environment.ĭocumentation for writing launcher scripts can be found in the You can do so by writing a "launcher script": this script will be called by Mocha Test Explorer (instead of its standard worker script) in a docker container or on another machine via ssh), If you want/need to run your tests in a remote environment (e.g. You're using for development, so if you're using VS Code Insiders, then you must set this variable to "stable".Ī sample project for running vscode-test tests using Mocha Test Explorer is available Note that this needs to be different from the version It specifies the version of VS Code to be used for testing. The environment variable VSCODE_VERSION is passed to the runTests() function from the vscode-test package, mochaExplorer.files, mochaExplorer.ui or mochaExplorer.require).
#Visual studio code test explorer install#
Install the mocha-explorer-launcher-scripts package and add the following settings to your project: "mochaExplorer.launcherScript": "node_modules/mocha-explorer-launcher-scripts/vscode-test",ĭepending on the structure of your project's tests you may have to add more settings Mocha Test Explorer supports running VS Code extension tests using vscode-test:


Running VS Code extension tests using vscode-test Watching files consumes system resources, so it shouldn't reference more files than necessary.įor this reason, ignore is set to **/node_modules/** by default. Make sure that it references the source files of your tests and of the application under test. MochaExplorer.watch can be a string, an array of strings or an object with the properties files and optionally ignore and debounce. "mochaExplorer.require": "source-map-support/register", For example: "mochaExplorer.files": "out/test/**/*.js", "mochaExplorer.require": "ts-node/register"Įnabling source-maps in your transpiler's configuration and running the transpiled test sources using theįurthermore, you should tell Mocha Test Explorer which files to watch for changes. Running the original (non-transpiled) sources directly by transpiling them on-the-fly using ts-node for Typescript, babel-register for Babel, etc.Įxample for Typescript: "mochaExplorer.files": "test/**/*.ts", The first one is easier to configure, the second one offers better performance (especially in large projects): If you use a transpiler in your project, there are 2 ways to make the tests work in Mocha Test Explorer. Using transpilers (Typescript, Babel, etc.) Run / Debug your tests using the / icons in the Test Explorer or the CodeLenses in your test file.mocharc.* file or a mocha property in your package.json or a mocha.opts file) Put your Mocha command line options (if you have any) in a mocha configuration file.Install the extension and restart VS Code.Lets you choose test suites or individual tests in the explorer that should be run automatically after each file change.Shows a failed test's log when the test is selected in the explorer.Adds line decorations to the source line where a test failed.Adds Gutter decorations to your test files showing the tests' state.Adds CodeLenses to your test files for starting and debugging tests.Shows a Test Explorer in the Test view in VS Code's sidebar with all detected tests and suites and their state.Mocha Test Explorer for Visual Studio Code
