speckjs

Comment Driven Development

speckjs

393

3

1.0.0

MIT

GitHub

Build Status

SpeckJS for Atom

About

SpeckJS is an npm module that parses JavaScript and outputs unit-tests. SpeckJS currently supports the Tape, Jasmine, and Mocha/Chai testing frameworks. Along with our Atom plugin, we have plugins available for Grunt, Gulp, as well as a standalone npm package.

Our goal with SpeckJS is to make it as easy as possible to get started using Test-Driven Development on a new project, to quickly add unit-tests to your existing project, or anywhere in between. We know the value of well-tested code, and SpeckJS is here to make that simpler than ever.

How to Use

Installation

Open Atom's Settings and navigate to the Install view.

For easy access, use Atom's command palette: cmd-shift-p (OSX) or ctrl-shift-p (Linux/Windows) and search for Settings View: Install Packages and Themes.

In the text field under Install Packages, make sure the Packages tab is selected. Now, simply search for speckjs, click install, and you're all set!

Creating a SpeckJS Comment

The first line of a SpeckJS comment is the title, describing your test block.

// test > sum function

Next, use SpeckJS' domain-specific language (DSL) to create an assertion of what you wish to test. Here's the format of the DSL:

// # <actual> <assertion-type> <expected> (<description>)

You can add as many (or as few) assertions as you'd like.

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

That's it! Here's a complete SpeckJS comment for the simple sum function:

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

Comments can also be written using block style comments:

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

Using the Plugin

We offer several easy ways to use SpeckJS in Atom.

Changing the Test Framework

By default, SpeckJS will build your test files using the Tape framework, but you can change this in the options. Here, we'll update our settings to build Jasmine tests, instead:

From Menu

Supported Assertion Types

These are the assertion types currently supported, and you can extend this list to include others in parsing/comment-conversion.js.

==   : equal
===  : deep equal
!==  : not equal
!=== : not deep equal

Support

SpeckJS is also available as a plugin for the following platforms:

Grunt

Gulp