For Mocha Rooster Regulation project. I’ve tried looking at the documentation and another tutorial, but assert.throws is a weird one and I have no idea what it wants in order to work, and I’ve tried a couple things.
const assert = require('assert');
const Rooster = require('../index');
describe('Rooster', () => {
describe('.timeAtDawn', () => {
it('throws an error if passed a number less than 0', () => {
// Define expected output
const err = new RangeError;
assert.throws(() => {
Rooster.timeAtDawn(-1);
}, err);
});
});
});
If it was coded correctly, it would pass. Instead I get the following output:
1) Rooster .timeAtDawn throws an error if passed a number less than 0:
TypeError: expected.call is not a function
at expectedException (assert.js:314:19)
at _throws (assert.js:360:8)
at Function.throws (assert.js:369:3)
at Context.it (test/index_test.js:33:14) // this is the line with assert.throws
npm ERR! Test failed. See above for more details.
I’ve tried other things that failed too.