@rhobweb/unit-test-utils

1.0.1 • Public • Published

@rhobweb/unit-test-utils

Overview

Simple framework for unit testing CJS Node.js modules using the following modules:

  • mocha - testing framework;
  • chai - assertion library;
  • sinon - test framework for stubs, spies and mocks;
  • nyc - code coverage checker;
  • rewire - allows access to the unexported items from the module under test;

Features

The following unexported module items may be stubbed for testing:

  • function;
  • class constructor.

Unexported module items, e.g., variables, required modules, may be accessed and faked.

Usage

See ./test/unit for example usage.

Testing

The following test scripts may be run from the command line:

  • npm run test
    • Runs the unit tests, code coverage and outputs the coverage stats.
  • npm run coverage
    • Generates the code coverage data in html format in the './coverage' directory.
  • npm run lint
    • Run eslint on the source and test code; if no errors are detected, only the lint command line is output.

Package Sidebar

Install

npm i @rhobweb/unit-test-utils

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

21.2 kB

Total Files

12

Last publish

Collaborators

  • rhobweb