JS Observation - How You Could Get False Positive Async Mocha.js Tests
TDD TV TDD TV
2.02K subscribers
365 views
0

 Published On May 6, 2016

You need to be aware of how async vs sync works when creating mocha tests.

If you don't understand async, you can end up writing tests where funny things happen and you don't know why.

Know which functions are long running and which aren't and be careful with that and where you are placing your assertions.

Here I show a neat way to demonstrate it. I show some tests that I used originally to test drive creation of my very own promise library. I show a scenario in which a test passes but shouldn't and why. The test has a long running function being called (setTimeout) yet if you're not careful, you can ignore the long running call and make the test pass prematurely.

show more

Share/Embed