I have installed mocha and chai globally. Another question is how to run these two tests synchroniously in a debug mode.
var describe = require ('mocha').describe;
var it = require ('mocha').it;
var before = require ('mocha').before;
var expect = require('chai').expect;
var assert = require('chai').assert;
var API = require('C:/Users/Niku/Desktop/api/api/controllers/API.js');
describe('getResponse tests', function() {
it('getResonse first from server and then from local', function(done) {
var ApI = new API(Id, key, List);
rep1 = API.getResponse();
assert.isNotEmpty(rep1);
console.log("1" + api_jwt);
assert.deepEqual(rep1, KPOAuthAPI.getResponse());
});
describe('getResponse from server after Timeout', function() {
it('getResponse should return the rep from local', function(done) {
var API = new API(Id, key, List);
var rep1 = API.getResponse();
assert.notEqual(rep, rep1);
});
});
Just delete var describe = require ('mocha').describe;
, because describe
function is setup by mocha. You need to only install mocha locally and run test.
Have you tried specifying the BDD argument to the mocha test runner, describe will only be availble if you specify the BDD style.
_mocha -u bdd
If you are using VS code, it should look like this in your launch.json
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"-u",
"bdd",
"--timeout",
"999999",
"--colors",
"${workspaceFolder}/dist/tests"
],
"internalConsoleOptions": "openOnSessionStart"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With