Git Product home page Git Product logo

assert-1's Introduction

Assert

A simple assertion library for server and client side JavaScript. Assert can be used with most test frameworks.

Browser Support: Android Browser 2.2–4.2, Firefox 3.6, Firefox 4–22, Google Chrome 14–28, Internet Explorer 6–10, Mobile Safari iOS 3–6, Safari 5–6

Assertions

All assertions throw AssertionError if they fail.

assert.fail( actual, expected, [message], [operator] )

Throw an assertion error.

assert.fail('foo', 'bar', 'Foo equals bar', '===');

assert.ok( value, [message] )

Assert that value is truthy.

assert.notOk( value, [message] )

Assert that value is falsy.

assert.equal( actual, expected, [message] )

Assert that actual == expected.

assert.notEqual( actual, expected, [message] )

Assert that actual != expected.

assert.strictEqual( actual, expected, [message] )

Assert that actual === expected.

assert.notStrictEqual( actual, expected, [message] )

Assert that actual !== expected.

assert.deepEqual( actual, expected, [message] )

Assert that actual is deeply equal to expected.

assert.notDeepEqual( actual, expected, [message] )

Assert that actual is not deeply equal to expected.

assert.throws( fn, [expected], [message] )

Assert that fn throws an error. If expected is present then the thrown error will be tested as follows:

  • If expected is a function, assert that error intanceof expected
  • If expected is a string, assert that error.message === expected
  • If expected is a RegExp, assert that expected.test(error) === true

assert.doesNotThrow( fn, [expected], [message] )

Assert that fn does not throw an error. If expected is present then the assertion is that an error can be thrown, but it does not pass the tests outlined in assert.throws.

assert.isTypeOf( actual, expected, [message] )

Assert that typeof actual === expected.

assert.isNotTypeOf( actual, expected, [message] )

Assert that typeof actual !== expected.

assert.isInstanceOf( actual, expected, [message] )

Assert that actual instanceof expected.

assert.isNotInstanceOf( actual, expected, [message] )

Assert that !(actual instanceof expected).

assert.isArray( value, [message] )

Assert that value is an array.

assert.isNotArray( value, [message] )

Assert that value is not an array.

assert.isBoolean( value, [message] )

Assert that value is a boolean.

assert.isNotBoolean( value, [message] )

Assert that value is not a boolean.

assert.isTrue( value, [message] )

Assert that value === true.

assert.isFalse( value, [message] )

Assert that value === false.

assert.isFunction( value, [message] )

Assert that value is a function.

assert.isNotFunction( value, [message] )

Assert that value is not a function.

assert.isNull( value, [message] )

Assert that value === null.

assert.isNotNull( value, [message] )

Assert that value !== null.

assert.isNumber( value, [message] )

Assert that value is a number.

assert.isNotNumber( value, [message] )

Assert that value is not a number.

assert.isObject( value, [message] )

Assert that value is an object.

assert.isNotObject( value, [message] )

Assert that value is not an object.

assert.isString( value, [message] )

Assert that value is a string.

assert.isNotString( value, [message] )

Assert that value is not a string.

assert.isUndefined( value, [message] )

Assert that value === undefined.

assert.isDefined( value, [message] )

Assert that value !== undefined.

assert.match( actual, expected, [message] )

Assert that actual matches the RegExp in expected.

assert.notMatch( actual, expected, [message] )

Assert that actual does not match the RegExp in expected.

assert.includes( haystack, needle, [message] )

Assert that haystack contains needle. For strings and arrays, this asserts that indexOf returns a value other than -1. For objects, this method asserts that needle is the name of a property on haystack.

assert.doesNotInclude( haystack, needle, [message] )

Assert that haystack does not contain needle. See assert.includes.

assert.lengthEquals( value, expected, [message] )

Assert that value.length === expected.

assert.lessThan( actual, expected, [message] )

Assert that actual < expected.

assert.lessThanOrEqual( actual, expected, [message] )

Assert that actual <= expected.

assert.greaterThan( actual, expected, [message] )

Assert that actual > expected.

assert.greaterThanOrEqual( actual, expected, [message] )

Assert that actual >= expected.

License

Assert is a fork of Procliam, licensed under the MIT license.

assert-1's People

Contributors

bartvds avatar dequea2 avatar rowanmanning 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.