Encountering an unfamiliar error while using Mocha with Chai for the first time has thrown me off guard. Having prior experience only with Jasmine, I'm struggling to pinpoint what mistake I might be making.
My objective is simple - ensuring that my constructor doesn't cause any errors. However, even after simplifying the code and arriving at this snippet, I still face the same perplexing issue:
class MyLib {
constructor() {}
}
export default MyLib;
Below is the content of the test file I am working with:
import chai from 'chai';
let { expect } = chai;
import MyLib from '../index';
describe('mylib-js', () => {
describe('constructor', () => {
it('should work', () => {
expect(new MyLib()).to.not.throw();
})
});
});
This represents the output generated by Mocha:
d:\path\to\mylib-js>mocha --require babel-core/register
mylib-js
constructor
1) should work
0 passing (23ms)
1 failing
1) mylib-js constructor should work:
AssertionError: expected {} to be a function
at Assertion.an (d:\path\to\mylib-js\node_modules\chai\lib\chai\core\assertions.js:169:10)
... // Truncated additional error details
The presence of {}
in the error message confuses me. What is this indicating or trying to convey?