Skip to content

Commit

Permalink
Fix tests for real
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jul 18, 2023
1 parent c881800 commit 125c48b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module.exports = function (api) {
let ignoreLib = true;
let includeRegeneratorRuntime = false;
let needsPolyfillsForOldNode = false;
let compileNodeModulesESM = false;

let transformRuntimeOptions;

Expand Down Expand Up @@ -130,7 +131,7 @@ module.exports = function (api) {
// When runing tests, we might need to compile some dependencies for old
// node versions. They might use ESM, which old Jest does not support.
// Jest will only run Babel in Node.js <= 10.
unambiguousSources.push("/**/node_modules");
compileNodeModulesESM = true;
targets = { node: "current" };
needsPolyfillsForOldNode = true;
break;
Expand Down Expand Up @@ -297,6 +298,11 @@ module.exports = function (api) {
].map(normalize),
plugins: [pluginImportMetaUrl],
},
compileNodeModulesESM && {
test: [normalize("/**/node_modules")],
sourceType: "unambiguous",
plugins: ["@babel/transform-modules-commonjs"],
},
{
test: sources.map(source => normalize(source.replace("/src", "/test"))),
plugins: [
Expand Down Expand Up @@ -360,6 +366,11 @@ function importInteropTest(source) {
if (source === "@babel/helper-plugin-test-runner") {
return "none";
}
// This file is native ESM, but we compile it to CJS in old versions of Node.
// TODO: Remove this case once we only test ESM.
if (source === "strip-ansi") {
return "babel";
}
if (
// non-test files
!source.startsWith(".") ||
Expand Down

0 comments on commit 125c48b

Please sign in to comment.