From 63b01210053d6a397a6c22cb8aa1e82a6e8d2000 Mon Sep 17 00:00:00 2001 From: code-pace Date: Sun, 21 Sep 2025 16:08:35 +0100 Subject: [PATCH] Fix: resolve Error: Could not determine the project root path Replaced new URL(import.meta.url).pathname with fileURLToPath(import.meta.url) when setting __filename variable during qa-shadow report generation. This ensures compatible Windows OS path --- constants.js | 4 ++-- constants.test.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/constants.js b/constants.js index ab9d070..3dad2bb 100644 --- a/constants.js +++ b/constants.js @@ -1,12 +1,12 @@ import chalk from 'chalk'; import fs from 'fs'; import path from 'path'; -import { pathToFileURL } from 'url'; +import { pathToFileURL, fileURLToPath } from 'url'; import dotenv from 'dotenv'; dotenv.config(); // Since __dirname is not available in ES modules, we need to derive it -const __filename = new URL(import.meta.url).pathname; +const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); // Function to find the project root directory diff --git a/constants.test.js b/constants.test.js index 28d9b73..f44451d 100644 --- a/constants.test.js +++ b/constants.test.js @@ -9,6 +9,8 @@ import { ALL_TEAM_NAMES, } from './constants.js'; +// Most test using the globally set mockConfigDetails will fail because on constants.js, +// shadowConfigDetails is encapsulated and not set as a global object describe('Constants', () => { const originalEnv = process.env; const mockConfigDetails = {