faq labelnode node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend that you _not_ install Mocha globally.describe("Array", () => {
describe("#indexOf()", () => {
it("shold return -1 when the value is not present", () => {
[1, 2, 3].indexOf(5).to.equal(-1);
[1, 2, 3].indexOf(2).to.equal(-1);
});
});
});
I followed the mocha getting started guide
Expected behavior: [What you expect to happen]
I think it should run without an error
Actual behavior: [What actually happens]
it displays the following:
1) Array
#indexOf()
shold return -1 when the value is not present:
TypeError: Cannot read property 'equal' of undefined
at Context.<anonymous> (test.js:8:16)
at processImmediate (internal/timers.js:456:21)
Reproduces how often: [What percentage of the time does it reproduce?]
mocha --version and node node_modules/.bin/mocha --version: 8.1.1node --version: v12.18.1This code is on the mochajs.org page 'Synchronous Code'

Assuming you're using Chai, it appears you forgot to wrap your actual value in expect().
Thanks for your answer. But I don't use Chai. I just followed the instructions on getting started page of mocha.
I just installed mocha.
That would explain it. Mocha is only a test runner rather than an assertion framework, so you'll have to add those separately if you want to use them.
Cool. Thak makes sense. Then the getting started page of mocha should comment about that in this section, I think.

Even in my experience, it was difficult for me to first understand exactly what mocha does too.
I think it would be nice if it was added more clearly to the documentation.