From 5614dc30ddf8a82163382bb864c0cbc608714d85 Mon Sep 17 00:00:00 2001 From: legalcodes Date: Fri, 20 Jan 2017 00:57:41 -0800 Subject: [PATCH] test: check error message in test-fs-make-callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a RegExp to `throws` assertions. PR-URL: https://github.com/nodejs/node/pull/10914 Reviewed-By: Colin Ihrig Reviewed-By: Michaƫl Zasso Reviewed-By: Italo A. Casas Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-fs-make-callback.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/test/parallel/test-fs-make-callback.js b/test/parallel/test-fs-make-callback.js index 6e4572ee35..40c9aa4299 100644 --- a/test/parallel/test-fs-make-callback.js +++ b/test/parallel/test-fs-make-callback.js @@ -2,6 +2,7 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); +const cbTypeError = /^TypeError: "callback" argument must be a function$/; function test(cb) { return function() { @@ -26,13 +27,13 @@ process.once('warning', common.mustCall((warning) => { assert.doesNotThrow(test()); function invalidArgumentsTests() { - assert.throws(test(null)); - assert.throws(test(true)); - assert.throws(test(false)); - assert.throws(test(1)); - assert.throws(test(0)); - assert.throws(test('foo')); - assert.throws(test(/foo/)); - assert.throws(test([])); - assert.throws(test({})); + assert.throws(test(null), cbTypeError); + assert.throws(test(true), cbTypeError); + assert.throws(test(false), cbTypeError); + assert.throws(test(1), cbTypeError); + assert.throws(test(0), cbTypeError); + assert.throws(test('foo'), cbTypeError); + assert.throws(test(/foo/), cbTypeError); + assert.throws(test([]), cbTypeError); + assert.throws(test({}), cbTypeError); }