Skip to content

Instantly share code, notes, and snippets.

@jrichardsz
Last active November 29, 2023 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrichardsz/eef6f5fd25b2ffdcb2f7376345cb9ad4 to your computer and use it in GitHub Desktop.
Save jrichardsz/eef6f5fd25b2ffdcb2f7376345cb9ad4 to your computer and use it in GitHub Desktop.
nodejs unit test snippets

run code before

nyc.config.js

module.exports = {
 include: "src/main/node/**/*.js",
 all : true,
 "hook-require": true ,
 'instrument': false
};
'use strict';

const { logConfig} = require('override-console-log'); 
logConfig.logDate = true; 
logConfig.enableLogD = process.env.VERBOSE_LOG;

module.exports = {
  "include": "src/main/node",
  "all" : true
};

.nycrc.json

{ "include": "src/main/node/**/*.js", "all" : true }

run test

"test": "nyc --reporter=html --reporter=json-summary mocha 'src/test/node/**/*.test.js' --exit --require mocha-suppress-logs --timeout 100000 && npm run badges",

run test - verbose

"test_verbose": "nyc --reporter=html --reporter=json-summary mocha 'src/test/node/**/*.test.js' --timeout 100000 --exit",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment