Skip to content

Commit 131c2c6

Browse files
committed
docs: Extend readme
1 parent 3b8f9f8 commit 131c2c6

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

README.md

+42-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ This is the Mocha extension for VS Code enabling developers to run and debug tes
1010
>
1111
> Please provide feedback and discuss improvements over at https://github.com/CoderLine/mocha-vscode/discussions
1212
13-
## Credits
14-
15-
This project started as a fork of the `Extension Test Runner` and `Command-line runner for VS Code tests` developed by Microsoft and then was adapted to work with Mocha directly.
16-
The main credits of this extension go over to the folks at Microsoft (and their contributors) and without them it would have been a lot more effort to ship a Mocha test runner for VS Code.
17-
18-
- https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner
19-
- https://github.com/microsoft/vscode-extension-test-runner
20-
- https://github.com/microsoft/vscode-test-cl
21-
2213
## Getting Started
2314

2415
Please follow the [general Mocha documentation](https://mochajs.org/) to initially set up tests using the command line. Then, [install this extension](https://marketplace.visualstudio.com/items?itemName=mocha.mocha-vscode).
@@ -34,3 +25,45 @@ This extension automatically discovers and works with the `.mocharc.js/cjs/yaml/
3425
- The `test` and `suite` identifiers the process extracts. Defaults to `["it", "test"]` and `["describe", "suite"]` respectively, covering Mocha's common interfaces.
3526

3627
- `mocha-vscode.debugOptions`: options, normally found in the launch.json, to pass when debugging the extension. See [the docs](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_launch-configuration-attributes) for a complete list of options.
28+
29+
## Features
30+
31+
### Show, Running and Debugging Tests
32+
33+
This plugin integrates with the built-in test explorer and editor of VS Code to show, run and debug tests.
34+
35+
The extension detects `.mocharc.<extension>` configuration files in any folder or workspace you open and will use it to discover the tests to be run.
36+
37+
![Show Run Debug](resources/show-run-debug.png)
38+
39+
### TypeScript and ESM integration
40+
41+
This extension is designed to work with both TypeScript, JavaScript (CJS/ESM) codebases assuming you already have a working setup with Mocha and TypeScript integrated.
42+
43+
To discover tests this extension dynamically translates your TypeScript or ESM code to CommonJS code (via [ESBuild](https://esbuild.github.io/)) and executes it partially to build up the test list. If this execution fails or you are having code which cannot be translated to CommonJS (e.g. top level awaits) this will result in errors.
44+
45+
For execution this extension will try to call directly the Mocha executable passing the `.mocharc` and additional arguments to it.
46+
47+
## Troubleshooting
48+
49+
### Check if Mocha itself works
50+
51+
If you face any issues the first step should be to check whether your tests are working with Mocha itself (outside this extension). Use `npx mocha` in your working and test directories to see whether tests are found and executed successfully. In this case you might [reach out to the Mocha folks](https://github.com/mochajs/mocha/blob/master/.github/CONTRIBUTING.md) to ask questions or report bugs.
52+
53+
### Check the output window
54+
55+
This extension creates a new output log channel where we print whats happening behind the scenes. You can also increase the log level in VS Code via the `Developer: Set Log Level...` command.
56+
57+
![Output Window](resources/output.png)
58+
59+
![Set Log Level](resources/set-log-level.png)
60+
61+
62+
## Credits
63+
64+
This project started as a fork of the `Extension Test Runner` and `Command-line runner for VS Code tests` developed by Microsoft and then was adapted to work with Mocha directly.
65+
The main credits of this extension go over to the folks at Microsoft (and their contributors) and without them it would have been a lot more effort to ship a Mocha test runner for VS Code.
66+
67+
- https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner
68+
- https://github.com/microsoft/vscode-extension-test-runner
69+
- https://github.com/microsoft/vscode-test-cl

resources/output.png

69.7 KB
Loading

resources/set-log-level.png

2.92 KB
Loading

resources/show-run-debug.png

67.2 KB
Loading

0 commit comments

Comments
 (0)