-
Notifications
You must be signed in to change notification settings - Fork 1
/
node-api-assert.txt
162 lines (107 loc) · 6.06 KB
/
node-api-assert.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
*node-api-assert.txt* For Node.js module `Assert` version v3.3.0.
Node.js Documentation
https://nodejs.org
==============================================================================
CONTENTS *node-api-contents*
1. Intro |node-api-assert|
2. Methods |node-api-assert-methods|
2.1. assert.fail(actual, expected, message, operator) |node-api-assert.fail()|
2.2. assert(value[, message]), assert.ok(value[, message]) |node-api-assert.ok()|
2.3. assert.equal(actual, expected[, message]) |node-api-assert.equal()|
2.4. assert.notEqual(actual, expected[, message]) |node-api-assert.notEqual()|
2.5. assert.deepEqual(actual, expected[, message]) |node-api-assert.deepEqual()|
2.6. assert.notDeepEqual(actual, expected[, message]) |node-api-assert.notDeepEqual()|
2.7. assert.strictEqual(actual, expected[, message]) |node-api-assert.strictEqual()|
2.8. assert.notStrictEqual(actual, expected[, message]) |node-api-assert.notStrictEqual()|
2.9. assert.deepStrictEqual(actual, expected[, message]) |node-api-assert.deepStrictEqual()|
2.10. assert.notDeepStrictEqual(actual, expected[, message]) |node-api-assert.notDeepStrictEqual()|
2.11. assert.throws(block[, error][, message]) |node-api-assert.throws()|
2.12. assert.doesNotThrow(block[, message]) |node-api-assert.doesNotThrow()|
2.13. assert.ifError(value) |node-api-assert.ifError()|
3. Properties |node-api-assert-properties|
==============================================================================
INTRO *node-api-assert*
Stability: 2 - Stable
This module is used for writing unit tests for your applications, you can
access it with `require('assert')`.
==============================================================================
METHODS *node-api-assert-methods*
------------------------------------------------------------------------------
assert.fail(actual, expected, message, operator) *node-api-assert.fail()*
Throws an exception that displays the values for `actual` and `expected` separated by the provided operator.
------------------------------------------------------------------------------
assert(value[, message]), assert.ok(value[, message]) *node-api-assert.ok()*
Tests if value is truthy, it is equivalent to `assert.equal(true, !!value, message);`
------------------------------------------------------------------------------
assert.equal(actual, expected[, message]) *node-api-assert.equal()*
Tests shallow, coercive equality with the equal comparison operator ( `==` ).
------------------------------------------------------------------------------
assert.notEqual(actual, expected[, message]) *node-api-assert.notEqual()*
Tests shallow, coercive non-equality with the not equal comparison operator ( `!=` ).
------------------------------------------------------------------------------
assert.deepEqual(actual, expected[, message]) *node-api-assert.deepEqual()*
Tests for deep equality. Primitive values are compared with the equal comparison
operator ( `==` ). Doesn't take object prototypes into account.
------------------------------------------------------------------------------
assert.notDeepEqual(actual, expected[, message]) *node-api-assert.notDeepEqual()*
Tests for any deep inequality. Opposite of `assert.deepEqual`.
------------------------------------------------------------------------------
assert.strictEqual(actual, expected[, message]) *node-api-assert.strictEqual()*
Tests strict equality, as determined by the strict equality operator ( `===` )
------------------------------------------------------------------------------
assert.notStrictEqual(actual, expected[, message]) *node-api-assert.notStrictEqual()*
Tests strict non-equality, as determined by the strict not equal
operator ( `!==` )
------------------------------------------------------------------------------
assert.deepStrictEqual(actual, expected[, message]) *node-api-assert.deepStrictEqual()*
Tests for deep equality. Primitive values are compared with the strict equality
operator ( `===` ).
------------------------------------------------------------------------------
assert.notDeepStrictEqual(actual, expected[, message]) *node-api-assert.notDeepStrictEqual()*
Tests for deep inequality. Opposite of `assert.deepStrictEqual`.
------------------------------------------------------------------------------
assert.throws(block[, error][, message]) *node-api-assert.throws()*
Expects `block` to throw an error. `error` can be constructor, `RegExp` or
validation function.
Validate instanceof using constructor:
>
assert.throws(
function() {
throw new Error("Wrong value");
},
Error
);
<
Validate error message using RegExp:
>
assert.throws(
function() {
throw new Error("Wrong value");
},
/value/
);
<
Custom error validation:
>
assert.throws(
function() {
throw new Error("Wrong value");
},
function(err) {
if ( (err instanceof Error) && /value/.test(err) ) {
return true;
}
},
"unexpected error"
);
<
------------------------------------------------------------------------------
assert.doesNotThrow(block[, message]) *node-api-assert.doesNotThrow()*
Expects `block` not to throw an error, see `assert.throws` for details.
------------------------------------------------------------------------------
assert.ifError(value) *node-api-assert.ifError()*
Tests if value is not a false value, throws if it is a true value. Useful when
testing the first argument, `error` in callbacks.
==============================================================================
PROPERTIES *node-api-assert-properties*
vim:tw=78:ts=8:ft=help