Skip to content

Commit 603900a

Browse files
committed
add test
1 parent ed9b857 commit 603900a

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

packages/ts-paths-resolve-plugin/integration.test.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
import { createRequire } from "module"
2+
import path from "node:path"
3+
import { fileURLToPath, pathToFileURL } from "node:url"
4+
5+
function getPathURL(basename) {
6+
return pathToFileURL(
7+
path.join(path.dirname(fileURLToPath(import.meta.url)), basename),
8+
)
9+
}
210

311
test("load CommonJS module", () => {
4-
const require = createRequire(import.meta.url)
12+
const require = createRequire(getPathURL("index.js"))
513
const fn = require(".")
614
expect(fn).toHaveProperty("name", "TsPathsResolvePlugin")
15+
expect(fn["default"]).toHaveProperty("name", "TsPathsResolvePlugin")
716
})
817

918
test("load ES module", async () => {

packages/vite-plugin-tsconfig-paths/integration.test.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import { createRequire } from "module"
2+
import path from "node:path"
3+
import { fileURLToPath, pathToFileURL } from "node:url"
24

5+
function getPathURL(basename) {
6+
return pathToFileURL(
7+
path.join(path.dirname(fileURLToPath(import.meta.url)), basename),
8+
)
9+
}
310
test("load CommonJS module", () => {
4-
const require = createRequire(import.meta.url)
11+
const require = createRequire(getPathURL("index.js"))
512
const fn = require(".")
613
expect(fn).toHaveProperty("name", "tsConfigPaths")
14+
expect(fn["default"]).toHaveProperty("name", "tsConfigPaths")
715
})
816

917
test("load ES module", async () => {

0 commit comments

Comments
 (0)