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

assert-no-throw

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assert-no-throw

Take an assertion library and return an assertion library that doesn't throw

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

For testing libraries that want to use an existing assertion library like the awesome power-assert, but collect all the results up without letting failed tests throw errors.

Usage

const noThrow = require('assert-no-throw')
const rawAssert = require('power-assert')

const assertWrapper = noThrow(rawAssert)

assertWrapper.assert.deepEqual({ thing: 'thingy' }, { thing: 'thingy' })
assertWrapper.assert.deepEqual({ thing: 'thingy' }, { thing: 'WAT' })

assertWrapper.results /* => [ 
	{ 
		method: 'deepEqual', 
		pass: true 
	}, { 
		method: 'deepEqual',
		pass: false,
		error: 
		{ 
			name: 'AssertionError',
			actual: [Object],
			expected: [Object],
			operator: 'deepEqual',
			message: '{ thing: \'thingy\' } deepEqual { thing: \'WAT\' }',
			generatedMessage: true 
		} 
	} 
]
*/

Result objects

Have these properties:

  • method: string, the name of the assertion method
  • pass: boolean, whether the assertion method threw an error or not
  • error: if pass is false, this should be an Error instance

Events

The assert wrapper object is an event emitter - it emits just one event, assert, whenever a method is called. The event contains an object matching the result object above.

License

WTFPL

Keywords

FAQs

Package last updated on 16 Jun 2017

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