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

assert-jsnext

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assert-jsnext

commonjs assert - node.js api compatible

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
366
increased by28.87%
Maintainers
1
Weekly downloads
 
Created
Source

assert

Build Status

This is a fork of the original assert package built to support projects built using dependencies with the jsnext:main field.


This module is used for writing unit tests for your applications, you can access it with require('assert-jsnext').

The API is derived from the commonjs 1.0 unit testing spec and the node.js assert module

fail(actual, expected, message, operator)

Throws an exception that displays the values for actual and expected separated by the provided operator.

value, message), ok(value, [message])

Tests if value is truthy, it is equivalent to equal(true, !!value, message);

equal(actual, expected, [message])

Tests shallow, coercive equality with the equal comparison operator ( == ).

notEqual(actual, expected, [message])

Tests shallow, coercive non-equality with the not equal comparison operator ( != ).

deepEqual(actual, expected, [message])

Tests for deep equality.

notDeepEqual(actual, expected, [message])

Tests for any deep inequality.

strictEqual(actual, expected, [message])

Tests strict equality, as determined by the strict equality operator ( === )

notStrictEqual(actual, expected, [message])

Tests strict non-equality, as determined by the strict not equal operator ( !== )

throws(block, [error], [message])

Expects block to throw an error. error can be constructor, regexp or validation function.

Validate instanceof using constructor:

throws(function() { throw new Error("Wrong value"); }, Error);

Validate error message using RegExp:

throws(function() { throw new Error("Wrong value"); }, /value/);

Custom error validation:

throws(function() {
    throw new Error("Wrong value");
}, function(err) {
    if ( (err instanceof Error) && /value/.test(err) ) {
        return true;
    }
}, "unexpected error");

doesNotThrow(block, [message])

Expects block not to throw an error, see throws for details.

ifError(value)

Tests if value is not a false value, throws if it is a true value. Useful when testing the first argument, error in callbacks.

Keywords

FAQs

Package last updated on 08 Sep 2015

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