Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

assert-in-order

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assert-in-order

assert a group of assertions are performed in order

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

assert-in-order

Assert a group of assertions are performed in order.

Synopsis

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[0](true)
group1[1](1, 1)

// These don't
try {
  var group2 = inOrder(assert, assertions)
  group2[1](1, 1)
  group2[0](true)
} 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)

group3.first(true)
group3.second(true)

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']
  })
  t.plan(group.length)
  group.first()
  group.second()
})

License

MIT

Keywords

FAQs

Package last updated on 12 Jan 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc