From a04bb452cd83bbfc0d297cfcebd99792ed7ab012 Mon Sep 17 00:00:00 2001 From: Arun Kumar Mohan Date: Fri, 17 Apr 2020 16:04:24 -0500 Subject: [PATCH] refactor(babel-node): Refactor babel-node tests configuration --- packages/babel-node/test/config.json | 11 +++++++++++ packages/babel-node/test/index.js | 16 +--------------- 2 files changed, 12 insertions(+), 15 deletions(-) create mode 100644 packages/babel-node/test/config.json diff --git a/packages/babel-node/test/config.json b/packages/babel-node/test/config.json new file mode 100644 index 000000000000..06c1c5853007 --- /dev/null +++ b/packages/babel-node/test/config.json @@ -0,0 +1,11 @@ +{ + "presets": [ + "../../babel-preset-env", + ["../../babel-preset-react"] + ], + "plugins": [ + "../../babel-plugin-transform-strict-mode", + "../../babel-plugin-transform-modules-commonjs" + ], + "only": ["../../../packages/*/test"] +} diff --git a/packages/babel-node/test/index.js b/packages/babel-node/test/index.js index 97ee54c02450..3ac90c7123f5 100644 --- a/packages/babel-node/test/index.js +++ b/packages/babel-node/test/index.js @@ -20,16 +20,6 @@ const outputFileSync = function(filePath, data) { fs.writeFileSync(filePath, data); }; -const presetLocs = [ - path.join(__dirname, "../../babel-preset-env"), - path.join(__dirname, "../../babel-preset-react"), -].join(","); - -const pluginLocs = [ - path.join(__dirname, "/../../babel-plugin-transform-strict-mode"), - path.join(__dirname, "/../../babel-plugin-transform-modules-commonjs"), -].join(","); - const readDir = function(loc, filter) { const files = {}; if (fs.existsSync(loc)) { @@ -105,12 +95,8 @@ const buildTest = function(binName, testName, opts) { return function(callback) { saveInFiles(opts.inFiles); - let args = [binLoc]; - - args.push("--presets", presetLocs, "--plugins", pluginLocs); - args.push("--only", "../../../../packages/*/test"); - + args.push("--config-file", "../config.json"); args = args.concat(opts.args); const spawn = child.spawn(process.execPath, args);