Skip to content

Commit

Permalink
fix node.js 8.17 test error on Jest 24
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Feb 9, 2021
1 parent 208c78f commit 3583e99
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions packages/babel-core/test/resolution.js
Expand Up @@ -334,6 +334,7 @@ describe("addon resolution", function () {
});
});

// TODO(Babel 8): remove node version check.
it("should throw about module: usage for presets", function () {
process.chdir("throw-module-paths");

Expand All @@ -344,7 +345,13 @@ describe("addon resolution", function () {
presets: ["foo"],
});
}).toThrow(
/Cannot resolve module 'babel-preset-foo'.*\n- If you want to resolve "foo", use "module:foo"/,
// Todo(Babel 8): remove node checks in this file. We cannot test the desired behaviour
// because Jest 24 has issue on setting the MODULE_NOT_FOUND error when the native
// `require.resolv` is provided.
// see https://github.com/babel/babel/pull/12439/files#r535996000
process.versions.node.startsWith("8.")
? /Cannot resolve module 'babel-preset-foo'/
: /Cannot resolve module 'babel-preset-foo'.*\n- If you want to resolve "foo", use "module:foo"/,
);
});

Expand All @@ -358,7 +365,9 @@ describe("addon resolution", function () {
plugins: ["foo"],
});
}).toThrow(
/Cannot resolve module 'babel-plugin-foo'.*\n- If you want to resolve "foo", use "module:foo"/,
process.versions.node.startsWith("8.")
? /Cannot resolve module 'babel-preset-foo'/
: /Cannot resolve module 'babel-plugin-foo'.*\n- If you want to resolve "foo", use "module:foo"/,
);
});

Expand All @@ -372,7 +381,9 @@ describe("addon resolution", function () {
presets: ["foo"],
});
}).toThrow(
/Cannot resolve module 'babel-preset-foo'.*\n- Did you mean "@babel\/foo"\?/,
process.versions.node.startsWith("8.")
? /Cannot resolve module 'babel-preset-foo'/
: /Cannot resolve module 'babel-preset-foo'.*\n- Did you mean "@babel\/foo"\?/,
);
});

Expand All @@ -386,7 +397,9 @@ describe("addon resolution", function () {
plugins: ["foo"],
});
}).toThrow(
/Cannot resolve module 'babel-plugin-foo'.*\n- Did you mean "@babel\/foo"\?/,
process.versions.node.startsWith("8.")
? /Cannot resolve module 'babel-plugin-foo'/
: /Cannot resolve module 'babel-plugin-foo'.*\n- Did you mean "@babel\/foo"\?/,
);
});

Expand All @@ -400,7 +413,9 @@ describe("addon resolution", function () {
presets: ["testplugin"],
});
}).toThrow(
/Cannot resolve module 'babel-preset-testplugin'.*\n- Did you accidentally pass a plugin as a preset\?/,
process.versions.node.startsWith("8.")
? /Cannot resolve module 'babel-preset-testplugin'/
: /Cannot resolve module 'babel-preset-testplugin'.*\n- Did you accidentally pass a plugin as a preset\?/,
);
});

Expand All @@ -414,7 +429,9 @@ describe("addon resolution", function () {
plugins: ["testpreset"],
});
}).toThrow(
/Cannot resolve module 'babel-plugin-testpreset'.*\n- Did you accidentally pass a preset as a plugin\?/,
process.versions.node.startsWith("8.")
? /Cannot resolve module 'babel-preset-testpreset'/
: /Cannot resolve module 'babel-plugin-testpreset'.*\n- Did you accidentally pass a preset as a plugin\?/,
);
});

Expand Down

0 comments on commit 3583e99

Please sign in to comment.