Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack Hot Module support + other options #69

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules
out
.rpt2_cache
*.vsix
33 changes: 31 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,42 @@
],
"outFiles": [
"${workspaceFolder}/out"
],
"skipFiles": [
"<node_internals>/**",
"resources/app/**"
]
},
{
"type": "node",
"request": "attach",
"name": "Mocha worker",
"processId": "${command:PickProcess}"
}
"processId": "${command:PickProcess}",
"skipFiles": [
"<node_internals>/**",
"node_modules/object.assign/**",
"node_modules/core-js/**",
"**/loader.js", // webpack hmr reloader
]
},
{
"name": "Debug Mocha Tests",
"type": "node",
"request": "attach",
"port": 9229,
"protocol": "inspector",
"timeout": 30000,
// "smartStep": true,
"sourceMaps": true,
"skipFiles": [
"<node_internals>/**",
"node_modules/core-js/**",
"node_modules/typescript/**",
"object.assign",
"node_modules/object.assign/**",
"node_modules/@babel/**",
"**/loader.js", // webpack hmr reloader
]
},
]
}
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"out": true,
".rpt2_cache": true
},
"mochaExplorer.debuggerConfig": "Debug Mocha Tests",
"mochaExplorer.timeout": 1000000000,
"editor.insertSpaces": false,
"editor.tabSize": 4,
"[json]": {
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mocha Test Explorer for Visual Studio Code

Run your Mocha tests using the
Run your Mocha tests using the
[Test Explorer UI](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer).

![Screenshot](img/screenshot.png)
Expand Down Expand Up @@ -55,6 +55,16 @@ to move your workspace to the remote environment. If you do so, your tests will
This is easier to set up (because you don't need to write a launcher script), but requires that your entire workspace and large
parts of VS Code run in the remote environment, which (depending on the environment) may be impractical or even impossible.

## Webpack HMR (Hot Module Reload) support

For big projects, or projects with a big compilation ovehead (i'm looking at you, Typescript users), testing can be a bit painful.

To remove overheads due to compilation & loading all your scripts, you can enable [Webpack HMR](https://webpack.js.org/concepts/hot-module-replacement/) with the `testExplorer.hmrBundle` option.

Using this option, tests can be updated/launched/debugged almost instantly, no matter your project size.

See [this repository](https://github.com/oguimbal/vscode-mocha-hmr-sample) for a sample implementation.

## Configuration

### Mocha command line options
Expand Down Expand Up @@ -110,6 +120,9 @@ Property | Description
`testExplorer.gutterDecoration` | Show the state of each test in the editor using Gutter Decorations
`testExplorer.onStart` | Retire or reset all test states whenever a test run is started
`testExplorer.onReload` | Retire or reset all test states whenever the test tree is reloaded
`testExplorer.nodeArgs` | Additional arguments passed to node (ex: --harmony-async-iteration)
`testExplorer.skipFrames` | When finding location of a test, those file frames will be skipped (useful if you are using "describe()" or "it()" wrappers)
`testExplorer.hmrBundle` | HMR (Hot Module Reload) Webpack bundle to watch

## Commands

Expand Down
Loading