Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including assert-in-order with all npm packages installed. Try it out:

var assertInOrder = require("assert-in-order")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

assert-in-order v0.0.3

assert a group of assertions are performed in order


Assert a group of assertions are performed in order.


var assert = require('assert')
var inOrder = require('./')

var assertions = [
 ['ok', 'first assertion'],
 ['equal', 'second assertion']

Each assertion should be an array whose first item is a method name. Any additional items are appended to the argument list when the assertion is called. For example, group[0](true) is equivalent to assert.ok(true, 'first assertion') with an additional ordering check.

var group1 = inOrder(assert, assertions)

assert.equal(group1.length, 2)

// These pass
group1[1](1, 1)

// These don't
try {
  var group2 = inOrder(assert, assertions)
  group2[1](1, 1)
} catch (err) {
  assert.equal(err.message, "assertion 1 was called before assertion 0")

// live life on the edge by abusing ordered object keys:
group3 = inOrder(assert, {
  first: ['ok', 'first assertion'],
  second: ['ok', 'second assertion']

assert.equal(group3.length, 2)


The ordering checks do not change the number of assertions that will be run so you can use this with [tap][] or [tape][] and test plans:

require('tape')('Assertion ordering', function (t) {
  var group = inOrder(t, {
    first: ['pass', 'radical'],
    second: ['pass', 'tubular']



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free