I'm getting the following error when running my test case with mocha
ReferenceError: describe is not defined
at Object.<anonymous> (/myproject/test/unit/physicalperson.spec.js:12:1)
Someone knows why this is happens?
package.json
"scripts": {
"test": "mocha"
},
physicalperson.spec.js
const request = require('supertest-as-promised');
const chai = require('chai');
const app = require('../../src/server');
const expect = chai.expect;
const PHYSICALPERSON_ENDPOINT = '/api/physicalperson';
describe('Integration tests for Physical Person', () => {
describe('\nFAIL Cases - Physical Person', () => {
it('should return 404 status if physical person is not present on database', (done) => {
request(app)
.get(`${PHYSICALPERSON_ENDPOINT}/xxap`)
.then((res) => {
expect(res.statusCode).to.equal(404);
done();
})
.catch((err) => {
done(err);
});
});
});
});
What I've Try
I saw some threads here in SO, and I also try the following code below, but the same error occurs.
var mocha = require('mocha')
var describe = mocha.describe
var it = mocha.it
var assert = require('chai').assert
describe('#indexOf()', function() {
it('should return -1 when not present', function() {
assert.equal([1,2,3].indexOf(4), -1)
})
})