From 4b6774463e6d992dee1cd9d67988ca1fa6464310 Mon Sep 17 00:00:00 2001 From: Dan Ribbens Date: Sat, 25 May 2024 17:57:32 -0400 Subject: [PATCH] chore: loader tests error on windows (#6508) --- test/loader/load.js | 5 ++--- test/loader/startChildProcess.ts | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/loader/load.js b/test/loader/load.js index 9463d16ae7..54dc645645 100644 --- a/test/loader/load.js +++ b/test/loader/load.js @@ -1,6 +1,6 @@ import fs from 'fs' import path from 'path' -import { fileURLToPath } from 'url' +import { fileURLToPath, pathToFileURL } from 'url' const filename = fileURLToPath(import.meta.url) const dirname = path.dirname(filename) @@ -17,8 +17,7 @@ export const load = async (filePath) => { 'Looks like payload has not been built. Please run `pnpm build:core` in the monorepo root', ) } - - const importConfigImport = await import(resolvedImportWithoutClientFilesPath) + const importConfigImport = await import(pathToFileURL(resolvedImportWithoutClientFilesPath).href) const importConfig = importConfigImport.importConfig const result = await importConfig(filePath) diff --git a/test/loader/startChildProcess.ts b/test/loader/startChildProcess.ts index cc4318ded9..513ea75d7a 100644 --- a/test/loader/startChildProcess.ts +++ b/test/loader/startChildProcess.ts @@ -1,6 +1,6 @@ import { spawn } from 'node:child_process' import { dirname } from 'node:path' -import { fileURLToPath } from 'node:url' +import { fileURLToPath, pathToFileURL } from 'node:url' import path from 'path' const _filename = fileURLToPath(import.meta.url) @@ -9,12 +9,12 @@ const _dirname = dirname(_filename) export const startChildProcess = async (filePath: string): Promise => { return new Promise((res) => { const childProcess = spawn('node', [path.resolve(_dirname, 'init.js')], { - stdio: 'inherit', env: { - PATH: process.env.PATH, - NODE_ENV: 'development', LOADER_TEST_FILE_PATH: filePath, + NODE_ENV: 'development', + PATH: process.env.PATH, }, + stdio: 'inherit', }) childProcess.on('close', (code) => {