Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Mocha Test Explorer with VScode when not in default `/test' folder

I am currently working on a project where the test files are stored in /code_tests instead of the default /test. I am trying to avoid having to rename the folder but I can't seem to change the default location for the Mocha Test Explorer.

The project is using Typescript on vscode.

The documentation provides this line of code. "mochaExplorer.files": "test/**/*.ts" which I assume would need to be changed to "mochaExplorer.files": "code_tests/**/*.ts" but I can't seem to find where to store this command for it to work as intended.

like image 231
Jeff d'Eon Avatar asked Jul 27 '20 22:07

Jeff d'Eon


People also ask

How do I open VS code in Test Explorer?

If the Test Explorer pane is not opened in your Visual Studio, you can access this as follows: in Visual Studio 2015 and 2017 - Test -> Windows -> Test Explorer; in Visual Studio 2019 and later - Test -> Test Explorer; or use keyboard shortcut Ctrl + E, T.


2 Answers

add these to vscode settings.json

"mochaExplorer.require": "ts-node/register",
"mochaExplorer.files": "code_tests/**/*.ts",
like image 80
Jeff d'Eon Avatar answered Nov 15 '22 05:11

Jeff d'Eon


Well if you don't have .vscode folder in you project structure, create one. And in .vscode/settings.json add the following

"mochaExplorer.require": "ts-node/register",
"mochaExplorer.files": "tests/**/*.ts",
like image 32
user3108503 Avatar answered Nov 15 '22 03:11

user3108503