Giter Club home page Giter Club logo

assert's Introduction

Assert

Minimalist unit testing library.

Installation and Usage

Installation

To add the library to a project, run:

npm i @stuymedova/assert

Usage

// tests.js
import { assert } from '@stuymedova/assert';

assert.equal('hello', 'world'); // Throws an AssertionError

To check, run in console:

node tests.js

API

assert.equal(actual, expected)

Throws an AssertionError if the given values are not equal. Values are compared using the strict equality operator (triple equals).

assert.notEqual(actual, expected)

Throws an AssertionError if the given values are equal. Values are compared using the strict equality operator (triple equals).

assert.equalReference(actual, expected)

Throws an AssertionError if the given variables do not referce the same object.

assert.deepEqual(actual, expected)

Throws an AssertionError if the given objects (incl. arrays) are not deeply equal (thay have the same number of key-value pairs, and all of them match).

assert.less(actual, expected)

Throws an AssertionError if the first passed value is greater than or equal to the second value.

assert.lessOrEqual(actual, expected)

Throws an AssertionError if the first passed value is greater than the second value.

assert.greater(actual, expected)

Throws an AssertionError if the first passed value is less than or equal to the second value.

assert.greaterOrEqual(actual, expected)

Throws an AssertionError if the first passed value is less than the second value.

assert.trapped(value, lowerBound, excludedUpperBound)

Throws an AssertionError if the given value is not within bounds or if the precondition is not satisfied (lower bound must be greater than the upper bound).

assert.equalType(actual, expected)

Throws an AssertionError if the given values are not of the same type.

assert.type(value, expectedType)

Throws an AssertionError if the given value's type does not match the given type.

assert.true(value)

Throws an AssertionError if the given value is not true.

assert.false(value)

Throws an AssertionError if the given value is not false.

assert's People

Contributors

stuymedova avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.