From a8b1c8bd70f616fa649761d9bba2e166a917204f Mon Sep 17 00:00:00 2001 From: calixteman Date: Sat, 21 Feb 2026 22:48:36 +0100 Subject: [PATCH] Remove the leading slash in windows file path when instrumenting js files for ccov --- test/webserver.mjs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/webserver.mjs b/test/webserver.mjs index 70b270ee0..ac36f1451 100644 --- a/test/webserver.mjs +++ b/test/webserver.mjs @@ -306,7 +306,15 @@ class WebServer { // Transform with Babel and istanbul plugin const result = babel.transformSync(content, { - filename: fileURL.pathname, + // On Windows, the file URL starts with a slash (e.g. + // /C:/path/to/file.js). + // This leading slash makes the file path invalid and causes the + // instrumentation to fail, so we need to remove it before passing the + // path. + filename: + process.platform === "win32" + ? fileURL.pathname.substring(1) + : fileURL.pathname, plugins: ["babel-plugin-istanbul"], sourceMaps: false, });