The assert module
provides a set of assertion functions for verifying invariants.
The module provides a recommended strict mode and a more lenient legacy mode.
See also:
Static variables
staticread onlystrict:Assert
In strict mode, assert functions use the comparison in the corresponding strict functions.
For example, Assert.deepEqual()
will behave like Assert.deepStrictEqual()
.
See also:
Static methods
staticdeepEqual<T>(actual:T, expected:T, ?message:String):Void
staticdeepEqual<T>(actual:T, expected:T, ?message:Error):Void
staticdeepStrictEqual<T>(actual:T, expected:T, ?message:String):Void
staticdeepStrictEqual<T>(actual:T, expected:T, ?message:Error):Void
Tests for deep equality between the actual
and expected
parameters.
"Deep" equality means that the enumerable "own" properties of child objects
are recursively evaluated also by the following rules.
See also:
staticdoesNotReject(asyncFn:Promise<Dynamic>, ?error:Dynamic ‑> Bool, ?message:String):Void
staticdoesNotReject(asyncFn:() ‑> Promise<Dynamic>, ?error:Class<Dynamic>, ?message:String):Void
staticdoesNotReject(asyncFn:() ‑> Promise<Dynamic>, ?error:RegExp, ?message:String):Void
staticdoesNotReject(asyncFn:() ‑> Promise<Dynamic>, ?error:Dynamic ‑> Bool, ?message:String):Void
staticdoesNotReject(asyncFn:Promise<Dynamic>, ?error:Class<Dynamic>, ?message:String):Void
staticdoesNotReject(asyncFn:Promise<Dynamic>, ?error:RegExp, ?message:String):Void
Awaits the asyncFn
promise or, if asyncFn
is a function,
immediately calls the function and awaits the returned promise to complete.
It will then check that the promise is not rejected.
See also:
staticdoesNotThrow(fn:() ‑> Void, ?error:Dynamic ‑> Bool, ?message:String):Void
staticdoesNotThrow(fn:() ‑> Void, ?error:Class<Dynamic>, ?message:String):Void
staticdoesNotThrow(fn:() ‑> Void, ?error:RegExp, ?message:String):Void
Asserts that the function fn
does not throw an error.
Using Assert.doesNotThrow()
is actually not useful because there is no benefit
in catching an error and then rethrowing it.
Instead, consider adding a comment next to the specific code path that should not throw
and keep error messages as expressive as possible.
See also:
staticequal<T>(actual:T, expected:T, ?message:Error):Void
staticequal<T>(actual:T, expected:T, ?message:String):Void
An alias of strictEqual
.
See also:
staticfail(?message:Error):Void
staticfail(?message:String):Void
Throws an AssertionError
with the provided error message or a default error message.
If the message
parameter is an instance of an Error
then it will be thrown instead of the AssertionError
.
See also:
staticfail_<T>(actual:T, expected:T, ?message:Error, ?operator_:String, ?stackStartFn:Function):Void
staticfail<T>(actual:T, expected:T, ?message:String, ?operator_:String, ?stackStartFn:Function):Void
Throws an AssertionError
. If message
is falsy, the error message is set as the values
of actual
and expected
separated by the provided operator
.
Otherwise, the error message is the value of message
.
See also:
staticifError(value:Dynamic):Void
Throws value
if value
is not undefined
or null
.
This is useful when testing the error
argument in callbacks.
The stack trace contains all frames from the error passed to ifError()
including the potential new frames for ifError()
itself.
See also:
staticnotDeepEqual<T>(actual:T, expected:T, ?message:String):Void
staticnotDeepEqual<T>(actual:T, expected:T, ?message:Error):Void
staticnotDeepStrictEqual<T>(actual:T, expected:T, ?message:String):Void
staticnotDeepStrictEqual<T>(actual:T, expected:T, ?message:Error):Void
staticnotEqual<T>(actual:T, expected:T, ?message:String):Void
staticnotEqual<T>(actual:T, expected:T, ?message:Error):Void
staticnotStrictEqual<T>(actual:T, expected:T, ?message:String):Void
staticnotStrictEqual<T>(actual:T, expected:T, ?message:Error):Void
Tests strict inequality between the actual
and expected
parameters as determined by the SameValue Comparison.
See also:
staticok(value:Dynamic, ?message:String):Void
staticok(value:Dynamic, ?message:Error):Void
staticrejects(asyncFn:Promise<Dynamic>, ?error:Error, ?message:String):Void
staticrejects(asyncFn:() ‑> Promise<Dynamic>, ?error:Class<Dynamic>, ?message:String):Void
staticrejects(asyncFn:() ‑> Promise<Dynamic>, ?error:RegExp, ?message:String):Void
staticrejects(asyncFn:() ‑> Promise<Dynamic>, ?error:Dynamic ‑> Bool, ?message:String):Void
staticrejects(asyncFn:() ‑> Promise<Dynamic>, ?error:Dynamic, ?message:String):Void
staticrejects(asyncFn:() ‑> Promise<Dynamic>, ?error:Error, ?message:String):Void
staticrejects(asyncFn:Promise<Dynamic>, ?error:Class<Dynamic>, ?message:String):Void
staticrejects(asyncFn:Promise<Dynamic>, ?error:RegExp, ?message:String):Void
staticrejects(asyncFn:Promise<Dynamic>, ?error:Dynamic ‑> Bool, ?message:String):Void
staticrejects(asyncFn:Promise<Dynamic>, ?error:Dynamic, ?message:String):Void
Awaits the asyncFn
promise or, if asyncFn
is a function,
immediately calls the function and awaits the returned promise to complete.
It will then check that the promise is rejected.
See also:
staticstrictEqual<T>(actual:T, expected:T, ?message:String):Void
staticstrictEqual<T>(actual:T, expected:T, ?message:Error):Void
Tests strict equality between the actual
and expected
parameter as
determined by the SameValue Comparison.
See also:
staticthrows(fn:() ‑> Void, ?error:Error, ?message:String):Void
staticthrows(fn:() ‑> Void, ?error:RegExp, ?message:String):Void
staticthrows(fn:() ‑> Void, ?error:Dynamic ‑> Bool, ?message:String):Void
staticthrows(fn:() ‑> Void, ?error:Dynamic, ?message:String):Void
Expects the function fn
to throw an error.
See also: