mocha-profiler

1.0.0 • Public • Published

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

  1. Install the package: npm i -D mocha-profiler
  2. Add the package to your .mocharc.js configuration file:
module.exports = {
 require: [
   'mocha-explorer',
 ],
}

Usage

  1. Run your test suite
  2. A file is generated in your current working directory

VS Code

  1. Install ms-vscode.vscode-js-profile-table VS Code extension
  2. Just click on the file from VS Code's explorer
  3. Enjoy

VS Code screenshot

Chrome

  1. In Chrome, navigate to chrome://inspect
  2. Open dedicated DevTools for Node
  3. Go to Profiler tab
  4. Right-click in the sidebar (below the Profiles header) and select Load...
  5. Navigate to the generated CPU profile and load it
  6. Enjoy

License

See the LICENSE file.

Dependencies (1)

Dev Dependencies (17)

Package Sidebar

Install

npm i mocha-profiler

Weekly Downloads

77

Version

1.0.0

License

BSD-3-Clause

Unpacked Size

16.6 kB

Total Files

14

Last publish

Collaborators

  • dreamscapes