mocha-profiler
v1.0.0
Published
Generate a CPU profile of your Mocha test suite execution
Downloads
124
Readme
mocha-profiler
Generate a CPU profile of your Mocha test suite execution
Overview
This Mocha hook allows you to generate a V8 CPU profile of your test suite's execution. The profiling starts immediately before the first test is run and ends immediately after all tests run. This is accomplished using Mocha's beforeAll()
and afterAll()
hooks.
The benefits of doing this are that the CPU profile will not include functions which get only executed during your application's startup or, even worse, on-the-fly source code compilation.
Installation
- Install the package:
npm i -D mocha-profiler
- Add the package to your .mocharc.js configuration file:
module.exports = {
require: [
'mocha-explorer',
],
}
Usage
- Run your test suite
- A file is generated in your current working directory
VS Code
- Install
ms-vscode.vscode-js-profile-table
VS Code extension - Just click on the file from VS Code's explorer
- Enjoy
Chrome
- In Chrome, navigate to chrome://inspect
- Open dedicated DevTools for Node
- Go to Profiler tab
- Right-click in the sidebar (below the Profiles header) and select Load...
- Navigate to the generated CPU profile and load it
- Enjoy
License
See the LICENSE file.