Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f3f19ee
net: refactor self=this to arrow functions
benjamingr Mar 23, 2016
0a13099
etw: add event messages
joaocgreis Mar 21, 2016
f14d71c
test: stdin is not always a net.Socket
Fishrock123 Mar 28, 2016
4f1fa2a
test: fix offending max-len linter error
thefourtheye Mar 31, 2016
96bb315
test: ensure _handle property existence
Trott Mar 26, 2016
c6ac6f2
http: Corrects IPv6 address in Host header
mpotra Feb 19, 2016
3f75751
build: introduce ci targets for lint/benchmark
jbergstroem Mar 27, 2016
a40b0cb
test: refactor http-end-throw-socket-handling
santigimeno Mar 12, 2016
8bec8aa
doc: consolidate timers docs in timers.markdown
bengl Mar 21, 2016
0ae5d02
doc: clarify that __dirname is module local
jasnell Apr 2, 2016
7337ef6
doc: minor argument formatting in stream.markdown
jasnell Apr 2, 2016
7491fdc
tools: remove disabling of already-disabled rule
Trott Apr 2, 2016
ce17371
doc: add 'Command Line Options' to 'View on single page'
firedfox Apr 2, 2016
f12c386
doc: clarify stdout/stderr arguments to callback
jasnell Apr 2, 2016
f879f5e
doc: document unspecified behavior for buf.write* methods
jasnell Mar 27, 2016
6052ced
test: fix error message checks in test-module-loading
jasnell Apr 1, 2016
0127c2b
test: fix test-dns.js flakiness
Trott Apr 1, 2016
dd25984
doc: note assert.throws() pitfall
Trott Apr 3, 2016
2ab1237
test: fix flaky test-net-socket-timeout-unref
Trott Mar 29, 2016
aa9fb03
doc: use HTTPS for links where possible
Trott Apr 2, 2016
1c40079
path: fix win32.isAbsolute() inconsistency
mscdex Apr 3, 2016
02f2ebd
test: explicitly set global in test-repl
Trott Apr 3, 2016
7db7a82
test: make arch available in status files
santigimeno Apr 1, 2016
cc8fcc5
test: be explicit about polluting of `global`
Trott Apr 2, 2016
059b607
test: make use of globals explicit
Trott Apr 2, 2016
0f5a51a
assert: Check typed array view type in deepEqual
addaleax Mar 26, 2016
50a062e
tools: remove obsolete lint config file
Trott Mar 30, 2016
8317778
meta: add "joining a wg" section to WORKING_GROUPS.md
mcollina Feb 29, 2016
781290b
doc: refine child_process detach behaviour
eljefedelrodeodeljefe Feb 19, 2016
5c4a414
2016-04-05, Version 5.10.1 (Stable) Release
Apr 5, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc: note assert.throws() pitfall
PR-URL: #6029
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and Myles Borins committed Apr 5, 2016
commit dd25984838f10f566edd9dfe76b4db358a52ef74
21 changes: 19 additions & 2 deletions doc/api/assert.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,13 @@ If the values are not strictly equal, an `AssertionError` is thrown with a

## assert.throws(block[, error][, message])

Expects the function `block` to throw an error. If specified, `error` can be a
constructor, [`RegExp`][], or validation function.
Expects the function `block` to throw an error.

If specified, `error` can be a constructor, [`RegExp`][], or validation
function.

If specified, `message` will be the message provided by the `AssertionError` if
the block fails to throw.

Validate instanceof using constructor:

Expand Down Expand Up @@ -402,6 +407,18 @@ assert.throws(
);
```

Note that `error` can not be a string. If a string is provided as the second
argument, then `error` is assumed to be omitted and the string will be used for
`message` instead. This can lead to easy-to-miss mistakes:

```js
// THIS IS A MISTAKE! DO NOT DO THIS!
assert.throws(myFunction, 'missing foo', 'did not throw with expected message');

// Do this instead.
assert.throws(myFunction, /missing foo/, 'did not throw with expected message');
```

[Locked]: documentation.html#documentation_stability_index
[`assert.deepEqual()`]: #assert_assert_deepequal_actual_expected_message
[`assert.deepStrictEqual()`]: #assert_assert_deepstrictequal_actual_expected_message
Expand Down