11package io .scalajs .nodejs
22
3+ import com .thoughtworks .enableIf
34import io .scalajs .nodejs .events .IEventEmitter
45
56import scala .scalajs .js
67import scala .scalajs .js .annotation .JSImport
8+ import scala .scalajs .js .|
79
810/**
911 * The assert module provides a simple set of assertion tests that can be used to test invariants. The module is
@@ -23,13 +25,7 @@ trait Assert extends IEventEmitter {
2325 */
2426 def apply (expression : js.Any , message : String = js.native): Unit = js.native
2527
26- /**
27- * Tests for deep equality between the actual and expected parameters. Primitive values are compared with the equal
28- * comparison operator ( == ). Only enumerable "own" properties are considered. The deepEqual() implementation does
29- * not test object prototypes, attached symbols, or non-enumerable properties. This can lead to some potentially
30- * surprising results.
31- * @example assert.deepEqual(actual, expected[, message])
32- */
28+ @ deprecated(" Use assert.deepStrictEqual() instead." , " stability 0" )
3329 def deepEqual (actual : js.Any , expected : js.Any , message : String = js.native): Unit = js.native
3430
3531 /**
@@ -39,14 +35,10 @@ trait Assert extends IEventEmitter {
3935 */
4036 def deepStrictEqual (actual : js.Any , expected : js.Any , message : String ): Unit = js.native
4137
42- /**
43- * Asserts that the function block does not throw an error. See assert.throws() for more details.
44- * When assert.doesNotThrow() is called, it will immediately call the block function. If an error is thrown
45- * and it is the same type as that specified by the error parameter, then an AssertionError is thrown. If the
46- * error is of a different type, or if the error parameter is undefined, the error is propagated back to the caller.
47- * @example assert.doesNotThrow(block[, error][, message])
48- */
49- def doesNotThrow (block : js.Function , error : js.Any , message : String ): Unit = js.native
38+ @ enableIf(io.scalajs.nodejs.CompilerSwitches .gteNodeJs10)
39+ def doesNotReject (asyncFn : js.Function | js.Promise [_],
40+ error : js.RegExp | js.Function = js.native,
41+ message : String = js.native): Unit = js.native
5042
5143 /**
5244 * Asserts that the function block does not throw an error. See assert.throws() for more details.
@@ -55,28 +47,26 @@ trait Assert extends IEventEmitter {
5547 * error is of a different type, or if the error parameter is undefined, the error is propagated back to the caller.
5648 * @example assert.doesNotThrow(block[, error][, message])
5749 */
58- def doesNotThrow (block : js.Function , message : String ): Unit = js.native
50+ def doesNotThrow (block : js.Function , error : js.RegExp | js.Function = js.native, message : String = js.native): Unit =
51+ js.native
5952
6053 /**
61- * Asserts that the function block does not throw an error. See assert.throws() for more details.
62- * When assert.doesNotThrow() is called, it will immediately call the block function. If an error is thrown
63- * and it is the same type as that specified by the error parameter, then an AssertionError is thrown. If the
64- * error is of a different type, or if the error parameter is undefined, the error is propagated back to the caller.
65- * @example assert.doesNotThrow(block[, error][, message])
54+ * @see https://nodejs.org/api/assert.html#assert_assert_equal_actual_expected_message
6655 */
67- def doesNotThrow (block : js.Function , error : js.Any = js.native): Unit = js.native
56+ @ deprecated(" Use assert.strictEqual() instead." , " stability 0" )
57+ def equal (actual : js.Any , expected : js.Any , message : String = js.native): Unit = js.native
6858
6959 /**
70- * Tests shallow, coercive equality between the actual and expected parameters using the equal comparison operator ( == ).
71- * @example assert.equal(actual, expected[, message])
60+ * @see https://nodejs.org/api/assert.html#assert_assert_fail_message
7261 */
73- def equal ( actual : js. Any , expected : js. Any , message : String = js.native ): Unit = js.native
62+ def fail ( message : String ): Unit = js.native
7463
7564 /**
76- * Throws an AssertionError. If message is falsy, the error message is set as the values of actual and expected
77- * separated by the provided operator. Otherwise, the error message is the value of message.
78- * @example assert.fail(actual, expected, message, operator)
65+ * @see https://nodejs.org/api/assert.html#assert_assert_fail_message
7966 */
67+ def fail (message : js.Error ): Unit = js.native
68+
69+ @ deprecated(" Use assert.fail([message]) or other assert functions instead." , " Node.js v10.0.0" )
8070 def fail (actual : js.Any , expected : js.Any , message : String , operator : String ): Unit = js.native
8171
8272 /**
@@ -85,10 +75,7 @@ trait Assert extends IEventEmitter {
8575 */
8676 def ifError (value : js.Any ): Unit = js.native
8777
88- /**
89- * Tests for any deep inequality. Opposite of assert.deepEqual().
90- * @example assert.notDeepEqual(actual, expected[, message])
91- */
78+ @ deprecated(" Use assert.notDeepStrictEqual() instead." , " stability 0" )
9279 def notDeepEqual (actual : js.Any , expected : js.Any , message : String = js.native): Unit = js.native
9380
9481 /**
@@ -97,10 +84,7 @@ trait Assert extends IEventEmitter {
9784 */
9885 def notDeepStrictEqual (actual : js.Any , expected : js.Any , message : String = js.native): Unit = js.native
9986
100- /**
101- * Tests shallow, coercive inequality with the not equal comparison operator ( != ).
102- * @example assert.notEqual(actual, expected[, message])
103- */
87+ @ deprecated(" Use assert.notStrictEqual() instead." , " stability 0" )
10488 def notEqual (actual : js.Any , expected : js.Any , message : String = js.native): Unit = js.native
10589
10690 /**
@@ -127,13 +111,22 @@ trait Assert extends IEventEmitter {
127111 * of the message parameter. If the message parameter is undefined, a default error message is assigned.
128112 * @example assert.throws(block[, error][, message])
129113 */
130- def throws (block : js.Function , error : js.Any , message : String = js.native): Unit = js.native
114+ def throws (block : js.Function ,
115+ error : js.RegExp | js.Function | js.Object | Error ,
116+ message : String = js.native): Unit = js.native
131117
118+ @ enableIf(io.scalajs.nodejs.CompilerSwitches .gteNodeJs10)
119+ def rejects (asyncFn : js.Function | js.Promise [_],
120+ error : js.RegExp | js.Function | js.Object | Error = js.native,
121+ message : String = js.native): Unit = js.native
132122}
133123
134124/**
135125 * Assert Singleton
136126 */
137127@ js.native
138128@ JSImport (" assert" , JSImport .Namespace )
139- object Assert extends Assert
129+ object Assert extends Assert {
130+ @ enableIf(io.scalajs.nodejs.CompilerSwitches .gteNodeJs10)
131+ val strict : Assert = js.native
132+ }
0 commit comments