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.
Open Atom's Settings and navigate to the
For easy access, use Atom's command palette:
cmd-shift-p (OSX) or
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
install, and you're all set!
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) */
We offer several easy ways to use SpeckJS in Atom.
From Atom's Command Palette, enter
From the Menu Bar, select Packages > SpeckJS > Build
Use the hotkey:
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:
These are the assertion types currently supported, and you can extend this list to include others in
== : equal === : deep equal !== : not equal !=== : not deep equal
SpeckJS is also available as a plugin for the following platforms:
Good catch. Let us know what about this package looks wrong to you, and we'll investigate right away.