Skip to content

Commit

Permalink
test: simplify loadModule special case handling for tests
Browse files Browse the repository at this point in the history
1. createRequire should have been properly handled in newer Jest
versions: jestjs/jest#9469
2. We don't test migrators with Jest mock modules anymore

So it's safe to skip that condition
  • Loading branch information
haoqunjiang committed Jan 20, 2021
1 parent 4e8a4ff commit 82aef12
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/@vue/cli-shared-utils/lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 82aef12

Please sign in to comment.