Skip to content

Commit

Permalink
fix: incorret babel.config.cts test fixtures (#17051)
Browse files Browse the repository at this point in the history
fix: incorret babel.config.cts test fixtures
  • Loading branch information
JLHwung authored Jan 9, 2025
1 parent 5fc3f75 commit d465131
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ export default [
"nodeGte20",
"nodeGte22_12",
"nodeLt22_12",
"nodeLt23_6",
"nodeGte12NoESM",
"testFn",
],
Expand Down
9 changes: 7 additions & 2 deletions packages/babel-core/test/config-ts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { loadPartialConfigSync } from "../lib/index.js";
import path from "path";
import semver from "semver";
import { USE_ESM, commonJS } from "$repo-utils";
import { USE_ESM, commonJS, itLt } from "$repo-utils";

const { __dirname, require } = commonJS(import.meta.url);

Expand All @@ -11,6 +11,9 @@ const { __dirname, require } = commonJS(import.meta.url);
// TODO: Make it work with USE_ESM.
const shouldSkip = semver.lt(process.version, "14.0.0") || USE_ESM;

// Node.js 23.6 unflags --experimental-strip-types
const nodeLt23_6 = itLt("23.6.0");

(shouldSkip ? describe : describe.skip)(
"@babel/core config with ts [dummy]",
() => {
Expand Down Expand Up @@ -38,7 +41,9 @@ const shouldSkip = semver.lt(process.version, "14.0.0") || USE_ESM;
expect(config.options.sourceRoot).toMatchInlineSnapshot(`"/a/b"`);
});

it("should throw with invalid .ts register", () => {
// Node.js >=23.6 has builtin .ts register, so this test can be removed
// when we dropped Node.js 23 support in the future
nodeLt23_6("should throw with invalid .ts register", () => {
require.extensions[".ts"] = () => {
throw new Error("Not support .ts.");
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
const path = require("path");
type config = any;
export default {
module.exports = {
targets: "node 12.0.0",
sourceRoot: path.posix.join("/a", "b"),
} as config;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
const path = require("path");
type config = any;
export default {
module.exports = {
targets: "node 12.0.0",
sourceRoot: path.posix.join("/a", "b"),
} as config;

0 comments on commit d465131

Please sign in to comment.