A port of Ruby's minitest assertions to JavaScript, ready to be consumed with mocha (or another runner).
Since mocha provides the necessary framework to run tests, this port of minitest focuses on the assertions part, which are first class citizens, then on everything that's built on those assertions (expectations) or related to them (eg: mocks, stubs).
Overall, the assertions are a direct port of their ruby counterparts, but modified to be compatible with javascript language bugs/features, and thus conforms to the CommonJS Unit Testing/1.0 test suite.
Please see http://ysbaddaden.github.io/minitest-js for usage and API documentation.
Minitest.js assumes that your browser support ECMAScript 5, either natively or through a polyfill and can be used in any browser, back to Internet Explorer 6.
Spec expectations (eg: mustEqual
), on the other end, do require native support
for Object.defineProperty
, which restrict support to modern engines only (eg:
Node.js, Internet Explorer 10+, Firefox 12+, etc). But thanks to a little hack,
we can support Firefox 3.6 and Internet Explorer 9 (unless we find another bug).
Minitest.js is compatible with the CommonJS Unit Testing/1.0 spec, but there are some differences since we follow minitest conventions.
The parameters have been flipped: use assert.equal(expected, actual)
instead of assert.equal(actual, expected)
.
Use refutations instead of assert not, so refute.equal()
replaces
assert.notEqual()
for instance.
The assert.equal
and refute.equal
assertions have been removed, because the
==
operator is unreliable, at best. Since deepEqual
does a better job to fix
its shortcomings, we renamed assert.deepEqual
and assert.notDeepEqual
to be
the actual assert.equal
and refute.equal
.
assert.strictEqual
and its refutation have been renamed to assert.same
(and
refute.same
).
Last but no least, assert
is itself an assertion, and assert.ok
is just an
alias for it. The same goes for refute
and refute.ok
.
minitest.js is distributed under the MIT license. Please see LICENSE.
minitest Copyright © Ryan Davis, seattle.rb
minitest.js Copyright © Julien Portalier