From 361d12e97c59fdcfa6504795a3b78e676266ed1e Mon Sep 17 00:00:00 2001 From: Alessio Gravili Date: Sun, 28 Apr 2024 16:04:11 -0400 Subject: [PATCH] chore: loader test: use importConfig helper instead of manually registering loader to realistically test what a user would experience --- test/loader/load.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/test/loader/load.js b/test/loader/load.js index 1d9ae8a07..9eec6e7bd 100644 --- a/test/loader/load.js +++ b/test/loader/load.js @@ -1,16 +1,10 @@ -import { register } from 'node:module' -import path from 'node:path' -import { fileURLToPath, pathToFileURL } from 'node:url' - export const load = async (filePath) => { - const filename = fileURLToPath(import.meta.url) - const dirname = path.dirname(filename) - const url = pathToFileURL(dirname).toString() + '/' + const importConfigImport = await import( + '../../packages/payload/dist/utilities/importWithoutClientFiles.js' + ) + const importConfig = importConfigImport.importConfig - // Need to register loader from payload/dist for a true test of functionality - register('../../packages/payload/dist/bin/loader/index.js', url) - - const result = await import(filePath) + const result = await importConfig(filePath) return result }