From 82aef123d9e4bbeec397023edc0c820672f79c8f Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Wed, 20 Jan 2021 16:37:47 +0800 Subject: [PATCH] test: simplify loadModule special case handling for tests 1. createRequire should have been properly handled in newer Jest versions: https://github.com/facebook/jest/pull/9469 2. We don't test migrators with Jest mock modules anymore So it's safe to skip that condition --- packages/@vue/cli-shared-utils/lib/module.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/@vue/cli-shared-utils/lib/module.js b/packages/@vue/cli-shared-utils/lib/module.js index c5f1953fbd..b6da0c4298 100644 --- a/packages/@vue/cli-shared-utils/lib/module.js +++ b/packages/@vue/cli-shared-utils/lib/module.js @@ -62,10 +62,9 @@ exports.resolveModule = function (request, context) { } exports.loadModule = function (request, context, force = false) { - // createRequire doesn't work with jest mock modules - // (which we used in migrator for inquirer, and in tests for cli-service) - // TODO: it's supported in Jest 25 - if (process.env.VUE_CLI_TEST && (request.endsWith('migrator') || context === '/')) { + // createRequire doesn't work with jest mocked fs + // (which we used in tests for cli-service) + if (process.env.VUE_CLI_TEST && context === '/') { return require(request) }