From 591a6927ee8f4182ade641b515fc0003e378cc3c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 17 Oct 2017 16:25:33 -0700 Subject: [PATCH] test: make test-querystring-escape engine agnostic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not check the error message if it is generated by the JavaScript engine (V8, ChakraCore, etc.). Do confirm that it is a `TypeError`. PR-URL: https://github.com/nodejs/node/pull/16272 Reviewed-By: Michaël Zasso Reviewed-By: Refael Ackermann Reviewed-By: Yuta Hiroto Reviewed-By: Joyee Cheung Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Tobias Nießen --- test/parallel/test-querystring-escape.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-querystring-escape.js b/test/parallel/test-querystring-escape.js index 18bece1ab13288..25a800a09a684c 100644 --- a/test/parallel/test-querystring-escape.js +++ b/test/parallel/test-querystring-escape.js @@ -28,12 +28,14 @@ assert.strictEqual( 'test' ); -// toString is not callable, must throw an error -assert.throws(() => qs.escape({ toString: 5 }), - /^TypeError: Cannot convert object to primitive value$/); +// `toString` is not callable, must throw an error. +// Error message will vary between different JavaScript engines, so only check +// that it is a `TypeError`. +assert.throws(() => qs.escape({ toString: 5 }), TypeError); -// should use valueOf instead of non-callable toString +// Should use valueOf instead of non-callable toString. assert.strictEqual(qs.escape({ toString: 5, valueOf: () => 'test' }), 'test'); -assert.throws(() => qs.escape(Symbol('test')), - /^TypeError: Cannot convert a Symbol value to a string$/); +// Error message will vary between different JavaScript engines, so only check +// that it is a `TypeError`. +assert.throws(() => qs.escape(Symbol('test')), TypeError);