Home

With Chimpy you can write your tests in a synchronous style. So you don’t have to deal with confusing promise chains or callback hell.

All the APIs that are shipped with Chimp can be used in a synchronous style by default. This includes the WebdriverIO commands, request module, and the DDP client.

Making asynchronous functions synchronous

If you have asynchronous functions that you want to use in your tests, you can wrap them with our helper functions wrapAsync and wrapAsyncObject. Both helpers work with asynchronous functions that return a promise or use a callback.

Example

You have an object myObject with an asynchronous method myFunc:

var myObject = {
  myFunc: function (callback) { ... }  // Asynchronous function
}

You wrap it with wrapAsyncObject:

var myObjectWrapper = wrapAsyncObject(myObject, ['myFunc'])

myObjectWrapper is:

myObjectWrapper = {
  myFunc: function () { ... } // Synchronous version
  myFuncSync: function () { ... } // Synchronous version
  myFuncAsync: function (callback) { ... } // Asynchronous version
}

myObject has not changed.

options

If you set this to false, you get this result instead:

myObjectWrapper = {
  myFunc: function (callback) { ... } // Asynchronous version
  myFuncSync: function () { ... } // Synchronous version
  myFuncAsync: function (callback) { ... } // Asynchronous version
}

myFunc is asynchronous.

If you want to use another function to wrap the asynchronous methods, you could pass it with this option.

Want to become a testing Ninja?

Checkout Xolv.io’s new Quality Faster guide where you can learn how to can bake quality in across the full stack using React, Node.JS, Jest, Meteor and more.