From 0c7f18ebd3a02d445a5f1882674a944bb7ccb4f6 Mon Sep 17 00:00:00 2001 From: Ruwan Geeganage Date: Tue, 30 Apr 2019 22:48:38 +0200 Subject: [PATCH] test: test error when breakOnSigint is not a boolean for evaluate PR-URL: https://github.com/nodejs/node/pull/27503 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Yongsheng Zhang Reviewed-By: Trivikram Kamat --- test/parallel/test-vm-module-errors.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/parallel/test-vm-module-errors.js b/test/parallel/test-vm-module-errors.js index c6f36c4483517c..a92863b1251c57 100644 --- a/test/parallel/test-vm-module-errors.js +++ b/test/parallel/test-vm-module-errors.js @@ -250,6 +250,20 @@ async function checkExecution() { })(); } +// Check for error thrown when breakOnSigint is not a boolean for evaluate() +async function checkInvalidOptionForEvaluate() { + await assert.rejects(async () => { + const m = new SourceTextModule('export const a = 1; export var b = 2'); + await m.evaluate({ breakOnSigint: 'a-string' }); + }, { + name: 'TypeError', + message: + 'The "options.breakOnSigint" property must be of type boolean. ' + + 'Received type string', + code: 'ERR_INVALID_ARG_TYPE' + }); +} + const finished = common.mustCall(); (async function main() { @@ -257,5 +271,6 @@ const finished = common.mustCall(); await checkModuleState(); await checkLinking(); await checkExecution(); + await checkInvalidOptionForEvaluate(); finished(); })();