# Running tests on Visual Studio Code

You can run your tests from Visual Studio Code by using one of its Mocha integration extensions. We recommend using Mocha Test Explorer.

To use Mocha Test Explorer, just install it and create a file named .mocharc.json in your project's root directory with the following contents:

  "require": ["@nomiclabs/buidler/register"],
  "timeout": 20000,
  "recursive": "test"

Finally, make sure you have the latest version of Mocha by running:

npm install --save-dev mocha

Now, you can set a shortcut for this VS Code command test-explorer.run-test-at-cursor, and you will be to run the test you are currently editing with it.

# Running TypeScript test

Running tests written in TypeScript from Visual Studio Code requires two extra steps.

First, you have to add this property to your .mocharc.json: "extension": ["ts"].

Then, you have to set the vscode option "mochaExplorer.files" to "test/**/*.{j,t}s".

If you need help, find us in the Buidler Support Discord server.

Last Updated: 9/4/2020, 8:38:45 PM