Mocha / Chai expect.to.throw not catching thrown errors
You have to pass a function to expect. Like this: expect(model.get.bind(model, ‘z’)).to.throw(‘Property does not exist in model schema.’); expect(model.get.bind(model, ‘z’)).to.throw(new Error(‘Property does not exist in model schema.’)); The way you are doing it, you are passing to expect the result of calling model.get(‘z’). But to test whether something is thrown, you have to pass a … Read more