-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
os: windowsp4-importantViolate documented behavior or significantly improves performance (priority)Violate documented behavior or significantly improves performance (priority)
Description
Describe the bug
After upgrading Vitest to 2.0.2, I get the error when import a file created in test:
import { afterEach, expect, it } from "vitest";
import { pathToFileURL } from "url";
import { unlinkSync, writeFileSync } from "fs";
const filename = "bar.js";
afterEach(() => unlinkSync(filename));
it("should works", async () => {
writeFileSync(filename, "export default 123");
const mod = await import(pathToFileURL(filename).href);
expect(mod.default).toBe(123);
});Error: Failed to load url /D:/Coding/JavaScript/vite-svg-sfc/bar.js (resolved id: /D:/Coding/JavaScript/vite-svg-sfc/bar.js). Does the file exist?
at loadAndTransform (file:///D:/Coding/JavaScript/vite-svg-sfc/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:52400:17)
at async ViteNodeServer._transformRequest (file:///D:/Coding/JavaScript/vite-svg-sfc/node_modules/.pnpm/vite-node@2.0.2_@types+node@20.14.10/node_modules/vite-node/dist/server.mjs:524:16)
at async ViteNodeServer._fetchModule (file:///D:/Coding/JavaScript/vite-svg-sfc/node_modules/.pnpm/vite-node@2.0.2_@types+node@20.14.10/node_modules/vite-node/dist/server.mjs:486:17)
at async Proxy.fetch (file:///D:/Coding/JavaScript/vite-svg-sfc/node_modules/.pnpm/vitest@2.0.2_@types+node@20.14.10/node_modules/vitest/dist/vendor/cli-api.FtQZKvQk.js:8093:22)
at async EventEmitter.<anonymous> (file:///D:/Coding/JavaScript/vite-svg-sfc/node_modules/.pnpm/vitest@2.0.2_@types+node@20.14.10/node_modules/vitest/dist/vendor/index.BpSiYbpB.js:69:20)
It works in Vitest 1.6.0
Reproduction
See above
System Info
System:
OS: Windows 11 10.0.22621
CPU: (12) x64 AMD Ryzen 5 5625U with Radeon Graphics
Memory: 6.20 GB / 15.31 GB
Binaries:
Node: 22.4.1 - D:\Program Files\NodeJS\node.EXE
npm: 10.8.1 - D:\Program Files\NodeJS\npm.CMD
pnpm: 9.5.0 - ~\AppData\Roaming\npm\pnpm.CMD
bun: 1.1.18 - ~\.bun\bin\bun.EXE
Browsers:
Edge: Chromium (124.0.2478.67)
Internet Explorer: 11.0.22621.3527Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
os: windowsp4-importantViolate documented behavior or significantly improves performance (priority)Violate documented behavior or significantly improves performance (priority)