From b5c8852ab5f44c0bc0e8ead6c3ad4c9fc25daee1 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 14 Feb 2017 11:00:34 -0800 Subject: [PATCH] doc: add missing function to test common doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add documentation for `common.expectsError()` to `test/README.md`. PR-URL: https://github.com/nodejs/node/pull/11382 Reviewed-By: James M Snell Reviewed-By: Gibson Fahnestock Reviewed-By: Michaƫl Zasso Reviewed-By: Joyee Cheung Reviewed-By: Luigi Pinca --- test/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/README.md b/test/README.md index 5ed028a1963..8affd257a76 100644 --- a/test/README.md +++ b/test/README.md @@ -180,6 +180,22 @@ Platform normalizes the `dd` command Check if there is more than 1gb of total memory. +### expectsError(code[, type[, message]]) +* `code` [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) + expected error must have this value for its `code` property +* `type` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) + expected error must be an instance of `type` +* `message` [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) + or [<RegExp>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) + if a string is provided for `message`, expected error must have it for its + `message` property; if a regular expression is provided for `message`, the + regular expression must match the `message` property of the expected error + +* return function suitable for use as a validation function passed as the second + argument to `assert.throws()` + +The expected error should be [subclassed by the `internal/errors` module](https://github.com/nodejs/node/blob/master/doc/guides/using-internal-errors.md#api). + ### expectWarning(name, expected) * `name` [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) * `expected` [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)