js-testing-introduction icon indicating copy to clipboard operation
js-testing-introduction copied to clipboard

async code refactor

Open rjoydip-zz opened this issue 6 years ago • 0 comments

Added expect.assertions(1) and return promise from test case.

Below notes taken from "Jest docs"

expect.assertions(number) verifies that a certain number of assertions are called during a test. This is often useful when testing asynchronous code, in order to make sure that assertions in a callback actually got called.```

If your code uses promises, there is a simpler way to handle asynchronous tests. Just return a promise from your test, and Jest will wait for that promise to resolve. If the promise is rejected, the test will automatically fail.```

rjoydip-zz avatar Oct 19 '18 08:10 rjoydip-zz