The JavaScript blog.


testing rest ES6 sponsored-content coverage

Wallaby.js Updates, Jasmine ES6 Tests, Chakram

Posted on .

Wallaby.js Updates

I recently wrote about Wallaby.js, and the authors have just released a major update that adds support for ES7, RequireJS, Browserify, and webpack. I'm a fan of Browserify so I was excited to see this -- you can get it at hwallabyjs/wallabify. The webpack postprocessor is available here: jeffling/wallaby-webpack.

Other updates include the news that a full-time developer has joined the project, and a tutorial that introduces the idea of live editing with testing.

Wallaby.js is an intelligent test runner for JavaScript projects, and has some cool features like editor-integrated code coverage reporting, and parallel test execution. It supports React JSX, popular test frameworks like Jasmine and Mocha, and even works with TypeScript and CoffeeScript.

Wallaby.js is a commercial product, but it's currently free during the preview. The site has more details on how to sign up for the preview: http://wallabyjs.com/.

Jasmine ES6 Tests

We're used to using transpilers for client-side code and sometimes Node projects, but what about tests? If ES6 really makes code more readable and maintainable, then I definitely want to use these language features to make my tests better! Torgeir Helgevold sent in a tutorial about writing Jasmine tests with ES6. The basic idea is to add preprocessors to a karma.config.js file that includes settings for Babel.

Karma is the test runner used by AngularJS, and it's test framework agnostic, so you could adapt this technique to work with Mocha as well.

Because Karma can easily be used to manipulate your test files before they execute, then it makes sense for people who want to use transpilers. I haven't done this before (my tests are usually very vanilla Mocha/assert tests), but it seems like a reasonable solution.

Chakram API Testing

Chakram (GitHub: dareid/chakram, License: MIT, npm: chakram) by Dan Reid is an API testing framework, based on promises. It includes Mocha and Chai, but instead of calling done callbacks you can use the wait method:

var chakram = require('chakram');  
var expect = chakram.expect;

describe('Minimal example', function() {  
  it('should provide a simple async testing framework', function() {
    var request = chakram.get('http://httpbin.org/get');
    return chakram.wait();

There's a list of extended chai expectations, and methods for HTTP and promises in the Chakram module documentation. This includes methods for HTTP verbs, so you can do chakram.patch and chakram.put.