@types/assert-plus
- Version 1.0.4
- Published
- 1 dependency
- MIT license
Install
npm i @types/assert-plus
yarn add @types/assert-plus
pnpm add @types/assert-plus
Overview
TypeScript definitions for assert-plus
Index
Functions
- array()
- arrayOfArray()
- arrayOfBool()
- arrayOfBuffer()
- arrayOfDate()
- arrayOfFinite()
- arrayOfFunc()
- arrayOfNumber()
- arrayOfObject()
- arrayOfRegexp()
- arrayOfStream()
- arrayOfString()
- arrayOfUuid()
- AssertionError()
- bool()
- buffer()
- date()
- deepEqual()
- doesNotThrow()
- equal()
- fail()
- finite()
- func()
- ifError()
- notDeepEqual()
- notEqual()
- notStrictEqual()
- number()
- object()
- ok()
- optionalArray()
- optionalArrayOfArray()
- optionalArrayOfBool()
- optionalArrayOfBuffer()
- optionalArrayOfDate()
- optionalArrayOfFinite()
- optionalArrayOfFunc()
- optionalArrayOfNumber()
- optionalArrayOfObject()
- optionalArrayOfRegexp()
- optionalArrayOfStream()
- optionalArrayOfString()
- optionalArrayOfUuid()
- optionalBool()
- optionalBuffer()
- optionalDate()
- optionalFinite()
- optionalFunc()
- optionalNumber()
- optionalObject()
- optionalRegexp()
- optionalStream()
- optionalString()
- optionalUuid()
- regexp()
- stream()
- strictEqual()
- string()
- throws()
- uuid()
Functions
function array
array: (arr: any[], message?: string) => void;
function arrayOfArray
arrayOfArray: (arr: any[][], message?: string) => void;
function arrayOfBool
arrayOfBool: (arr: boolean[], message?: string) => void;
function arrayOfBuffer
arrayOfBuffer: (arr: Buffer[], message?: string) => void;
function arrayOfDate
arrayOfDate: (arr: Date[], message?: string) => void;
function arrayOfFinite
arrayOfFinite: (arr: number[], message?: string) => void;
function arrayOfFunc
arrayOfFunc: (arr: any[], message?: string) => void;
function arrayOfNumber
arrayOfNumber: (arr: number[], message?: string) => void;
function arrayOfObject
arrayOfObject: (arr: any[], message?: string) => void;
function arrayOfRegexp
arrayOfRegexp: (arr: RegExp[], message?: string) => void;
function arrayOfStream
arrayOfStream: (arr: Stream[], message?: string) => void;
function arrayOfString
arrayOfString: (arr: string[], message?: string) => void;
function arrayOfUuid
arrayOfUuid: (arr: string[], message?: string) => void;
function AssertionError
AssertionError: (options: any, message?: string) => void;
function bool
bool: (bool: boolean, message?: string) => void;
function buffer
buffer: (buffer: Buffer, message?: string) => void;
function date
date: (date: Date, message?: string) => void;
function deepEqual
deepEqual: <T>(actual: T, expected: T, message?: string) => void;
Tests for deep equality between the
actual
andexpected
parameters. Primitive values are compared with the equal comparison operator (==
).Only enumerable "own" properties are considered. The
deepEqual()
implementation does not test object prototypes, attached symbols, or non-enumerable properties. This can lead to some potentially surprising results. For example, the following example does not throw anAssertionError
because the properties on the Error object are non-enumerable:// WARNING: This does not throw an AssertionError!assert.deepEqual(Error('a'), Error('b'));"Deep" equality means that the enumerable "own" properties of child objects are evaluated also.
If the values are not equal, an
AssertionError
is thrown with amessage
property set equal to the value of themessage
parameter. If themessage
parameter is undefined, a default error message is assigned.
function doesNotThrow
doesNotThrow: (block: any, error?: any, message?: string) => void;
Asserts that the function
block
does not throw an error. Seeassert.throws()
for more details.When
assert.doesNotThrow()
is called, it will immediately call theblock
function.If an error is thrown and it is the same type as that specified by the
error
parameter, then anAssertionError
is thrown. If the error is of a different type, or if theerror
parameter is undefined, the error is propagated back to the caller.The following, for instance, will throw the TypeError because there is no matching error type in the assertion:
assert.doesNotThrow(() => {throw new TypeError('Wrong value');},SyntaxError);However, the following will result in an
AssertionError
with the message 'Got unwanted exception (TypeError)..':assert.doesNotThrow(() => {throw new TypeError('Wrong value');},TypeError);If an
AssertionError
is thrown and a value is provided for themessage
parameter, the value ofmessage
will be appended to theAssertionError
message:assert.doesNotThrow(() => {throw new TypeError('Wrong value');},TypeError,'Whoops');// Throws: AssertionError: Got unwanted exception (TypeError). Whoops
function equal
equal: (actual: any, expected: any, message?: string) => void;
Tests shallow, coercive equality between the actual and expected parameters using the equal comparison operator (
==
).const assert = require('assert');assert.equal(1, 1);// OK, 1 == 1assert.equal(1, '1');// OK, 1 == '1'assert.equal(1, 2);// AssertionError: 1 == 2assert.equal({a: {b: 1}}, {a: {b: 1}});//AssertionError: { a: { b: 1 } } == { a: { b: 1 } }If the values are not equal, an
AssertionError
is thrown with amessage
property set equal to the value of themessage
parameter. If themessage
parameter is undefined, a default error message is assigned.
function fail
fail: (actual: any, expected: any, message: any, operator: any) => void;
Throws an
AssertionError
. Ifmessage
is falsy, the error message is set as the values ofactual
andexpected
separated by the providedoperator
. Otherwise, the error message is the value ofmessage
.const assert = require('assert');assert.fail(1, 2, undefined, '>');// AssertionError: 1 > 2assert.fail(1, 2, 'whoops', '>');// AssertionError: whoops
function finite
finite: (finite: number, message?: string) => void;
function func
func: (func: any, message?: string) => void;
function ifError
ifError: (value: any) => void;
Throws
value
ifvalue
is truthy. This is useful when testing theerror
argument in callbacks.const assert = require('assert');assert.ifError(0);// OKassert.ifError(1);// Throws 1assert.ifError('error');// Throws 'error'assert.ifError(new Error());// Throws Error
function notDeepEqual
notDeepEqual: (actual: any, expected: any, message?: string) => void;
Tests for any deep inequality. Opposite of
assert.deepEqual()
.const assert = require('assert');const obj1 = { a : { b : 1 } };const obj2 = { a : { b : 2 } };const obj3 = { a : { b : 1 } };const obj4 = Object.create(obj1);assert.notDeepEqual(obj1, obj1);// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }assert.notDeepEqual(obj1, obj2);// OK, obj1 and obj2 are not deeply equalassert.notDeepEqual(obj1, obj3);// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }assert.notDeepEqual(obj1, obj4);// OK, obj1 and obj2 are not deeply equalIf the values are deeply equal, an
AssertionError
is thrown with amessage
property set equal to the value of themessage
parameter. If themessage
parameter is undefined, a default error message is assigned.
function notEqual
notEqual: (actual: any, expected: any, message?: string) => void;
Tests shallow, coercive inequality with the not equal comparison operator (
!=
).const assert = require('assert');assert.notEqual(1, 2);// OKassert.notEqual(1, 1);// AssertionError: 1 != 1assert.notEqual(1, '1');// AssertionError: 1 != '1'If the values are equal, an
AssertionError
is thrown with amessage
property set equal to the value of themessage
parameter. If themessage
parameter is undefined, a default error message is assigned.
function notStrictEqual
notStrictEqual: (actual: any, expected: any, message?: string) => void;
Tests strict inequality as determined by the strict not equal operator (
!==
).const assert = require('assert');assert.notStrictEqual(1, 2);// OKassert.notStrictEqual(1, 1);// AssertionError: 1 !== 1assert.notStrictEqual(1, '1');// OKIf the values are strictly equal, an
AssertionError
is thrown with amessage
property set equal to the value of themessage
parameter. If themessage
parameter is undefined, a default error message is assigned.
function number
number: (number: number, message?: string) => void;
function object
object: (obj: any, message?: string) => void;
function ok
ok: (options: any, message?: string) => void;
Tests if
value
is truthy. It is equivalent toassert.equal(!!value, true, message)
.If
value
is not truthy, anAssertionError
is thrown with amessage
property set equal to the value of themessage
parameter. If themessage
parameter isundefined
, a default error message is assigned.const assert = require('assert');assert.ok(true);// OKassert.ok(1);// OKassert.ok(false);// throws "AssertionError: false == true"assert.ok(0);// throws "AssertionError: 0 == true"assert.ok(false, 'it\'s false');// throws "AssertionError: it's false"
function optionalArray
optionalArray: (arr: any[] | undefined, message?: string) => void;
function optionalArrayOfArray
optionalArrayOfArray: (arr: any[][] | undefined, message?: string) => void;
function optionalArrayOfBool
optionalArrayOfBool: (arr: boolean[] | undefined, message?: string) => void;
function optionalArrayOfBuffer
optionalArrayOfBuffer: (arr: Buffer[] | undefined, message?: string) => void;
function optionalArrayOfDate
optionalArrayOfDate: (arr: Date[] | undefined, message?: string) => void;
function optionalArrayOfFinite
optionalArrayOfFinite: (arr: number[] | undefined, message?: string) => void;
function optionalArrayOfFunc
optionalArrayOfFunc: (arr: any[] | undefined, message?: string) => void;
function optionalArrayOfNumber
optionalArrayOfNumber: (arr: number[] | undefined, message?: string) => void;
function optionalArrayOfObject
optionalArrayOfObject: (arr: any[] | undefined, message?: string) => void;
function optionalArrayOfRegexp
optionalArrayOfRegexp: (arr: RegExp[] | undefined, message?: string) => void;
function optionalArrayOfStream
optionalArrayOfStream: (arr: Stream[] | undefined, message?: string) => void;
function optionalArrayOfString
optionalArrayOfString: (arr: string[] | undefined, message?: string) => void;
function optionalArrayOfUuid
optionalArrayOfUuid: (arr: string[] | undefined, message?: string) => void;
function optionalBool
optionalBool: (bool: boolean | undefined, message?: string) => void;
function optionalBuffer
optionalBuffer: (buffer: Buffer | undefined, message?: string) => void;
function optionalDate
optionalDate: (options: Date | undefined, message?: string) => void;
function optionalFinite
optionalFinite: (options: number | undefined, message?: string) => void;
function optionalFunc
optionalFunc: (options: any, message?: string) => void;
function optionalNumber
optionalNumber: (options: number | undefined, message?: string) => void;
function optionalObject
optionalObject: (options: any, message?: string) => void;
function optionalRegexp
optionalRegexp: (options: RegExp | undefined, message?: string) => void;
function optionalStream
optionalStream: (options: Stream | undefined, message?: string) => void;
function optionalString
optionalString: (options: string | undefined, message?: string) => void;
function optionalUuid
optionalUuid: (options: string | undefined, message?: string) => void;
function regexp
regexp: (regexp: RegExp, message?: string) => void;
function stream
stream: (stream: Stream, message?: string) => void;
function strictEqual
strictEqual: <T>(actual: T, expected: T, message?: string) => void;
Tests strict equality as determined by the strict equality operator (
===
).const assert = require('assert');assert.strictEqual(1, 2);// AssertionError: 1 === 2assert.strictEqual(1, 1);// OKassert.strictEqual(1, '1');// AssertionError: 1 === '1'If the values are not strictly equal, an
AssertionError
is thrown with amessage
property set equal to the value of themessage
parameter. If themessage
parameter is undefined, a default error message is assigned.
function string
string: (str: string, message?: string) => void;
function throws
throws: (block: any, error?: any, message?: string) => void;
function uuid
uuid: (uuid: string, message?: string) => void;
Package Files (1)
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/assert-plus
.
- Markdown[](https://www.jsdocs.io/package/@types/assert-plus)
- HTML<a href="https://www.jsdocs.io/package/@types/assert-plus"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 466 ms. - Missing or incorrect documentation? Open an issue for this package.