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
This commit is contained in:
Haoqun Jiang
2021-01-20 16:37:47 +08:00
parent 4e8a4ff03a
commit 82aef123d9
+3 -4
View File
@@ -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)
}