@@ -6,25 +6,11 @@ This module is used so that Node.js can test itself. It can be accessed with
6
6
` require('assert') ` . However, it is recommended that a userland assertion
7
7
library be used instead.
8
8
9
- ## assert.fail(actual, expected, message, operator)
10
-
11
- Throws an exception that displays the values for ` actual ` and ` expected `
12
- separated by the provided operator.
13
-
14
9
## assert(value[ , message] ), assert.ok(value[ , message] )
15
10
16
11
Tests if value is truthy. It is equivalent to
17
12
` assert.equal(!!value, true, message) ` .
18
13
19
- ## assert.equal(actual, expected[ , message] )
20
-
21
- Tests shallow, coercive equality with the equal comparison operator ( ` == ` ).
22
-
23
- ## assert.notEqual(actual, expected[ , message] )
24
-
25
- Tests shallow, coercive inequality with the not equal comparison operator
26
- ( ` != ` ).
27
-
28
14
## assert.deepEqual(actual, expected[ , message] )
29
15
30
16
Tests for deep equality. Primitive values are compared with the equal
@@ -39,27 +25,72 @@ non-enumerable:
39
25
// WARNING: This does not throw an AssertionError!
40
26
assert.deepEqual(Error('a'), Error('b'));
41
27
28
+ ## assert.deepStrictEqual(actual, expected[ , message] )
29
+
30
+ Tests for deep equality. Primitive values are compared with the strict equality
31
+ operator ( ` === ` ).
32
+
33
+ ## assert.doesNotThrow(block[ , error] [ , message ] )
34
+
35
+ Expects ` block ` not to throw an error. See [ assert.throws()] ( #assert_assert_throws_block_error_message ) for more details.
36
+
37
+ If ` block ` throws an error and if it is of a different type from ` error ` , the
38
+ thrown error will get propagated back to the caller. The following call will
39
+ throw the ` TypeError ` , since we're not matching the error types in the
40
+ assertion.
41
+
42
+ assert.doesNotThrow(
43
+ function() {
44
+ throw new TypeError("Wrong value");
45
+ },
46
+ SyntaxError
47
+ );
48
+
49
+ In case ` error ` matches with the error thrown by ` block ` , an ` AssertionError `
50
+ is thrown instead.
51
+
52
+ assert.doesNotThrow(
53
+ function() {
54
+ throw new TypeError("Wrong value");
55
+ },
56
+ TypeError
57
+ );
58
+
59
+ ## assert.equal(actual, expected[ , message] )
60
+
61
+ Tests shallow, coercive equality with the equal comparison operator ( ` == ` ).
62
+
63
+ ## assert.fail(actual, expected, message, operator)
64
+
65
+ Throws an exception that displays the values for ` actual ` and ` expected `
66
+ separated by the provided operator.
67
+
68
+ ## assert.ifError(value)
69
+
70
+ Throws ` value ` if ` value ` is truthy. This is useful when testing the ` error `
71
+ argument in callbacks.
72
+
42
73
## assert.notDeepEqual(actual, expected[ , message] )
43
74
44
75
Tests for any deep inequality. Opposite of ` assert.deepEqual ` .
45
76
46
- ## assert.strictEqual (actual, expected[ , message] )
77
+ ## assert.notDeepStrictEqual (actual, expected[ , message] )
47
78
48
- Tests strict equality as determined by the strict equality operator ( ` === ` ).
79
+ Tests for deep inequality. Opposite of ` assert.deepStrictEqual ` .
80
+
81
+ ## assert.notEqual(actual, expected[ , message] )
82
+
83
+ Tests shallow, coercive inequality with the not equal comparison operator
84
+ ( ` != ` ).
49
85
50
86
## assert.notStrictEqual(actual, expected[ , message] )
51
87
52
88
Tests strict inequality as determined by the strict not equal operator
53
89
( ` !== ` ).
54
90
55
- ## assert.deepStrictEqual(actual, expected[ , message] )
56
-
57
- Tests for deep equality. Primitive values are compared with the strict equality
58
- operator ( ` === ` ).
59
-
60
- ## assert.notDeepStrictEqual(actual, expected[ , message] )
91
+ ## assert.strictEqual(actual, expected[ , message] )
61
92
62
- Tests for deep inequality. Opposite of ` assert.deepStrictEqual ` .
93
+ Tests strict equality as determined by the strict equality operator ( ` === ` ) .
63
94
64
95
## assert.throws(block[ , error] [ , message ] )
65
96
@@ -97,34 +128,3 @@ Custom error validation:
97
128
},
98
129
"unexpected error"
99
130
);
100
-
101
- ## assert.doesNotThrow(block[ , error] [ , message ] )
102
-
103
- Expects ` block ` not to throw an error. See [ assert.throws()] ( #assert_assert_throws_block_error_message ) for more details.
104
-
105
- If ` block ` throws an error and if it is of a different type from ` error ` , the
106
- thrown error will get propagated back to the caller. The following call will
107
- throw the ` TypeError ` , since we're not matching the error types in the
108
- assertion.
109
-
110
- assert.doesNotThrow(
111
- function() {
112
- throw new TypeError("Wrong value");
113
- },
114
- SyntaxError
115
- );
116
-
117
- In case ` error ` matches with the error thrown by ` block ` , an ` AssertionError `
118
- is thrown instead.
119
-
120
- assert.doesNotThrow(
121
- function() {
122
- throw new TypeError("Wrong value");
123
- },
124
- TypeError
125
- );
126
-
127
- ## assert.ifError(value)
128
-
129
- Throws ` value ` if ` value ` is truthy. This is useful when testing the ` error `
130
- argument in callbacks.
0 commit comments