From 146681b76c8102c2cfc6a65b130b17dbb2b2d777 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 31 Dec 2018 16:57:18 -0800 Subject: [PATCH] test: simplify flags logic for esm tests --- test/es-module/test-esm-loader-dependency.mjs | 15 +++++++-------- test/es-module/test-esm-loader-invalid-format.mjs | 11 ++++------- ...sm-loader-missing-dynamic-instantiate-hook.mjs | 7 ++----- test/es-module/test-esm-named-exports.mjs | 10 ++++------ test/es-module/test-esm-shared-loader-dep.mjs | 9 ++++----- 5 files changed, 21 insertions(+), 31 deletions(-) diff --git a/test/es-module/test-esm-loader-dependency.mjs b/test/es-module/test-esm-loader-dependency.mjs index b8e06879d3550a..125dfed63ffd87 100644 --- a/test/es-module/test-esm-loader-dependency.mjs +++ b/test/es-module/test-esm-loader-dependency.mjs @@ -3,11 +3,10 @@ import '../fixtures/es-modules/test-esm-ok.mjs'; // We just test that this module doesn't fail loading -const flag = '--loader=./test/fixtures/es-module-loaders/loader-with-dep.mjs'; -if (!process.execArgv.includes(flag)) { - (async () => { - const { requireFlags } = await import('../common'); - // Include `--experimental-modules` explicitly for workers. - requireFlags('--experimental-modules', flag); - })(); -} +(async () => { + const { requireFlags } = await import('../common'); + requireFlags( + '--experimental-modules', + '--loader=./test/fixtures/es-module-loaders/loader-with-dep.mjs' + ); +})(); diff --git a/test/es-module/test-esm-loader-invalid-format.mjs b/test/es-module/test-esm-loader-invalid-format.mjs index 59dff6075a604a..66afe664a7da24 100644 --- a/test/es-module/test-esm-loader-invalid-format.mjs +++ b/test/es-module/test-esm-loader-invalid-format.mjs @@ -1,13 +1,10 @@ import { expectsError, mustCall, requireFlags } from '../common'; import assert from 'assert'; -const flag = - '--loader=./test/fixtures/es-module-loaders/loader-invalid-format.mjs'; - -if (!process.execArgv.includes(flag)) { - // Include `--experimental-modules` explicitly for workers. - requireFlags('--experimental-modules', flag); -} +requireFlags( + '--experimental-modules', + '--loader=./test/fixtures/es-module-loaders/loader-invalid-format.mjs' +); import('../fixtures/es-modules/test-esm-ok.mjs') .then(assert.fail, expectsError({ diff --git a/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs b/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs index 1a0b80d5d82cb3..7fa0ebfb0eaabf 100644 --- a/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs +++ b/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs @@ -1,13 +1,10 @@ import { expectsError, requireFlags } from '../common'; -const flag = +const longFlag = '--loader=' + './test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs'; -if (!process.execArgv.includes(flag)) { - // Include `--experimental-modules` explicitly for workers. - requireFlags('--experimental-modules', flag); -} +requireFlags('--experimental-modules', longFlag); import('test').catch(expectsError({ code: 'ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK', diff --git a/test/es-module/test-esm-named-exports.mjs b/test/es-module/test-esm-named-exports.mjs index a52949950c4f23..5318a62c5a6dd6 100644 --- a/test/es-module/test-esm-named-exports.mjs +++ b/test/es-module/test-esm-named-exports.mjs @@ -3,12 +3,10 @@ import { readFile } from 'fs'; import assert from 'assert'; import ok from '../fixtures/es-modules/test-esm-ok.mjs'; -const flag = - '--loader=./test/fixtures/es-module-loaders/builtin-named-exports-loader.mjs'; -if (!process.execArgv.includes(flag)) { - // Include `--experimental-modules` explicitly for workers. - requireFlags('--experimental-modules', flag); -} +requireFlags( + '--experimental-modules', + '--loader=./test/fixtures/es-module-loaders/builtin-named-exports-loader.mjs' +); assert(ok); assert(readFile); diff --git a/test/es-module/test-esm-shared-loader-dep.mjs b/test/es-module/test-esm-shared-loader-dep.mjs index 30d322853f2389..3c00788babee96 100644 --- a/test/es-module/test-esm-shared-loader-dep.mjs +++ b/test/es-module/test-esm-shared-loader-dep.mjs @@ -3,10 +3,9 @@ import assert from 'assert'; import '../fixtures/es-modules/test-esm-ok.mjs'; import dep from '../fixtures/es-module-loaders/loader-dep.js'; -const flag = '--loader=./test/fixtures/es-module-loaders/loader-shared-dep.mjs'; -if (!process.execArgv.includes(flag)) { - // Include `--experimental-modules` explicitly for workers. - requireFlags('--experimental-modules', flag); -} +requireFlags( + '--experimental-modules', + '--loader=./test/fixtures/es-module-loaders/loader-shared-dep.mjs' +); assert.strictEqual(dep.format, 'esm');