Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion debugging-mocha-tests/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.2.0",
"version": "0.2.1",
"configurations": [
{
"type": "node",
Expand Down
34 changes: 25 additions & 9 deletions debugging-mocha-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,18 @@ If you don't have all of your tests under a common "test" directory, then the fo
}
```

If you are running mocha will multiple arguments, you may consider creating an opt file that store all these arguments (i.e name it as mocha.opts).
If you are running mocha will multiple arguments, you may consider creating an opt file that store all these arguments (i.e name it as mocha.json).

Example file contents with mocha arguments:
Example file contents with mocha arguments:

```
--timeout 999999
--colors
--full-trace
```json
{
"colors": true,
"timeout": 999999
}
```

Reference the mocha opts file with --opts in configuration as shown below
Reference the mocha config file with --config in configuration as shown below

```json
{
Expand All @@ -127,8 +128,8 @@ Reference the mocha opts file with --opts in configuration as shown below
"name": "Mocha Test All with Options",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"--opts",
"${workspaceFolder}/support/mocha.opts",
"--config",
"${workspaceFolder}/support/mocha.json",
"${workspaceFolder}/test"
],
"console": "integratedTerminal",
Expand All @@ -141,6 +142,8 @@ Reference the mocha opts file with --opts in configuration as shown below
}
```

Mocha supports [many configuration](https://mochajs.org/#configuring-mocha-nodejs), typical of modern command-line tools.

## Debugging all tests

You can debug all tests by following the steps below:
Expand All @@ -164,3 +167,16 @@ You can debug the test you're editing by following the steps below:
3. Your breakpoint will now be hit

![current](current.gif)

## Tips

If you be warned by `Configured debug type 'pwa-node' is not supported.` in VSCode

Update the content of the `.vscode/settings.json` with the following configurations:

```json
{
"debug.chrome.useV3": true,
"debug.javascript.usePreview": false
}
```
7 changes: 5 additions & 2 deletions debugging-mocha-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
"test": "mocha 'test/**/*.spec.js'"
},
"author": "Jag Reehal",
"contributors": [
"Alfred Dagenais <jesuis@alfreddagenais.com> (https://www.alfreddagenais.com)"
],
"license": "ISC",
"dependencies": {
"chai": "4.1.2",
"mocha": "4.1.0"
"chai": "4.2.0",
"mocha": "8.1.3"
}
}
4 changes: 4 additions & 0 deletions debugging-mocha-tests/support/mocha.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"colors": true,
"timeout": 999999
}
2 changes: 0 additions & 2 deletions debugging-mocha-tests/support/mocha.opts

This file was deleted.