terst
A JavaScript testing component with a terse syntax. Supported in both Node.js and the browser.
Why?
Take a look at some of the popular JavaScript assertion/testing libraries, most of them are overly verbose.
examples from should.js docs:
var user = name: 'tj' pets: 'tobi' 'loki' 'jane' 'bandit'; usershouldhave;usershouldhavewith;
or...
how about from expect.js:
to;tobe;tobe;
or..
Don't even get me started on Node.js assert.
Terst has three main advantages:
- There are only six methods to remember. You aren't second guessing what each method really does or constantly referring to the documentation.
- Your eyes can quickly scan down the left side of your tests to quickly interpret what each test should do. Terst forces you to be very explicit.
- It's very lightweight.
Install
Node.js/Browserify
npm install --save terst
Component
component install jprichardson/terst
Script
Methods
T (value, [msg])
Asserts if the value is truthy.
F (value, [msg])
Asserts if the value is falsey.
EQ (val1, val2, [msg])
Asserts if val1
strictly equals val2
.
NEQ (val1, val2, [msg])
Asserts if val
does not strictly equal val2
.
APPROX (value, expected, delta, [msg])
Asserts if the value is within +- the delta.
THROWS (fun)
Asserts if a function throws i.e. if it does not throw, there is an error.
NOTE: For descriptive errors, you can set terse.autoMsg = true
. It's experimental only.
License
(MIT License)
Copyright 2013-2014, JP Richardson jprichardson@gmail.com