January 2018
Beginner
658 pages
13h 10m
English
Now the reason this test is passing is not because the assertion in utils.test.js is valid. It's passing because we have an asynchronous action that takes 1 second. This function will return before the async callback gets fired. When I say function returning, I'm referring to the callback function, the second argument to it.
This is when Mocha thinks your test is done. This means that these assertions never run. The Mocha output has already said our test passes before this callback ever gets fired. What we need to do is tell Mocha this will be an asynchronous test that'll take time. To do this, all we do is we provide an argument inside the callback function we pass to it. We'll call this one done:
it('should async ...Read now
Unlock full access