| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9e9bfa4 commit b28f6a5
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,11 +7,13 @@ access it with `require('assert')`. | |||
| 7 | 7 | ||
| 8 | 8 | ## assert.fail(actual, expected, message, operator) | |
| 9 | 9 | ||
| 10 | - Throws an exception that displays the values for `actual` and `expected` separated by the provided operator. | ||
| 10 | + Throws an exception that displays the values for `actual` and `expected` | ||
| 11 | + separated by the provided operator. | ||
| 11 | 12 | ||
| 12 | 13 | ## assert(value[, message]), assert.ok(value[, message]) | |
| 13 | 14 | ||
| 14 | - Tests if value is truthy. It is equivalent to `assert.equal(true, !!value, message)`. | ||
| 15 | + Tests if value is truthy. It is equivalent to | ||
| 16 | + `assert.equal(true, !!value, message)`. | ||
| 15 | 17 | ||
| 16 | 18 | ## assert.equal(actual, expected[, message]) | |
| 17 | 19 | ||
@@ -86,9 +88,31 @@ Custom error validation: | |||
| 86 | 88 | "unexpected error" | |
| 87 | 89 | ); | |
| 88 | 90 | ||
| 89 | - ## assert.doesNotThrow(block[, message]) | ||
| 91 | + ## assert.doesNotThrow(block[, error][, message]) | ||
| 90 | 92 | ||
| 91 | - Expects `block` not to throw an error. See `assert.throws()` for details. | ||
| 93 | + Expects `block` not to throw an error. See [assert.throws()](#assert_assert_throws_block_error_message) for more details. | ||
| 94 | + | ||
| 95 | + If `block` throws an error and if it is of a different type from `error`, the | ||
| 96 | + thrown error will get propagated back to the caller. The following call will | ||
| 97 | + throw the `TypeError`, since we're not matching the error types in the | ||
| 98 | + assertion. | ||
| 99 | + | ||
| 100 | + assert.doesNotThrow( | ||
| 101 | + function() { | ||
| 102 | + throw new TypeError("Wrong value"); | ||
| 103 | + }, | ||
| 104 | + SyntaxError | ||
| 105 | + ); | ||
| 106 | + | ||
| 107 | + In case `error` matches with the error thrown by `block`, an `AssertionError` | ||
| 108 | + is thrown instead. | ||
| 109 | + | ||
| 110 | + assert.doesNotThrow( | ||
| 111 | + function() { | ||
| 112 | + throw new TypeError("Wrong value"); | ||
| 113 | + }, | ||
| 114 | + TypeError | ||
| 115 | + ); | ||
| 92 | 116 | ||
| 93 | 117 | ## assert.ifError(value) | |
| 94 | 118 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments