Speck JS

Written by Ramon Gebben

SpeckJS (GitHub: speckjs/speckjs, License: MIT, npm: speckjs)

SpeckJS is a library that parses JavaScript comments and outputs unit-tests. SpeckJS currently supports Tape, Jasmine, and Mocha/Chai.

SpeckJS comes with plugins for Grunt, Gulp and Atom.

The goal of SpeckJS is to make it as easy as possible to get started using Test-Driven Development on a new project or to quickly add unit-tests to your existing project.

Let’s make a test.

test > sum function
# sum(1, 2) == 3 (returns the sum of both params)
# sum(3, 4) == 7 (returns the sum of both params)

function sum(a, b){
    return a + b;

SpeckJS supports some basic assertion like: equal, strict equal, not equal. Besides relying on all the tools already provided, such as gulp and atom plugins, you could also script yourself with the API like this:

var speck = require('speckjs');

// file object to be passed as an argument
var file = {
  name: 'demo.js',
  content: scriptContent

// options hash selecting Jasmine and specifying a callback
var option = {
  testFW: 'jasmine',
  onBuild: function(data) {

// Returns Jasmine test file
var result = speck.build(file, option);

We will start using this in my company from now on, because it makes it a lot easier to integrate testing in a long running project that has never being tested just by walking through the files. I hope to see other people pick this up aswel.