Skip to content

Tag: mocha.js

Write assertion subject to whether key has value

I’m trying to come up with a method that would allow me to create a it block that confirms whether my configuration file has a specific attribute. The object has in it: I would like to have an it block that would confirm whether this value is true and if it isn’t, then it should fail. I have tried…

mocha test passes even though I throw error

in this block of code “err” is being printed, and the test passes. also tried – and done(). nothing worked, test is still passing every time. why is this happening? Answer Option 1: await the promise Just add await before the promise expression. You don’t even need those then and catch…

Mocha test false assert timeouts

I have some problem with my async mocha tests. The assert method within a promise results in a timeout when the input evaluates to false. (with true values it works fine) This is a simplified version of the problem. We usually do networking instead of this constructed promise. Answer You’d better NOT us…

Compare arrays of Errors in Chai

I have a validator method that returns an array with Errors. I want to create a unit test that compares this errors, but I can’t use expect(fn).to.throw since I don’t throw the errors, just return them. This is my approach but I get AssertionError: expected [ Array(2) ] to have the same members as…