Unit Testing Hacks

Arun Rajeevan
1 min readJan 23, 2020

--

const mocha = require(‘mocha’);
const sinon = require(‘sinon’);
let describe; let it; let before; let after;
if (mocha.describe) {
describe = mocha.describe;
it = mocha.it;
before = mocha.before;
after = mocha.after;
} else {
describe = global.describe;
it = global.it;
before = global.before;
after = global.after;
}

{

“type”: “node”,

“request”: “launch”,

“name”: “Mocha current file”,

“program”: “${workspaceRoot}/node_modules/mocha/bin/_mocha”,

“runtimeArgs”: [

“-r”,

“dotenv/config”

],

“args”: [

“-u”,

“tdd”,

“ — timeout”,

“999999”,

“ — colors”,

“${file}”

],

“internalConsoleOptions”: “openOnSessionStart”

},

“test”: “nyc — reporter=html npm run mochaTest”,
“mochaTest”: “mocha — recursive ./test/unit — reporter mochawesome”

{
“allowedMemberTypes”: [
“User”,
“Application”
],
“description”: “Read only access”,
“displayName”: “Read Only”,
“id”: “19ea27d1–84d1–4062-ac77–63b2c1b248f0”,
“isEnabled”: true,
“lang”: null,
“origin”: “Application”,
“value”: “ReadOnly”
}

nyc — reporter=lcov — reporter=text-lcov mocha — recursive ./test/unit

--

--

No responses yet