Back
Close

Tools for Promises Unit Testing

Venkat.R
32.1K views
Previous: Unit Testing with Dependent Files

Async.js

Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with Node.js and installable via npm install --save async, it can also be used directly in the browser.

In this below example, We use async.parallel where we need to trigger the DB Service Method at the same time.

Service File

Unit Testing

Similar to Previous example, Added Mocha, Chai and Sinon and added only one example for success scenario.

Mainly we are by passing the DB Methods db.userData and db.activityData and return the custom data using Sinon Stub.

In this test case, we are checking the expected result is deeply equal to the method response.

Unit Testing with Async.js

Cool, Isn’t it !!

Happy Coding, Stay tuned for next one !

Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io