chore: loader test: use importConfig helper instead of manually registering loader to realistically test what a user would experience
This commit is contained in:
@@ -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) => {
|
export const load = async (filePath) => {
|
||||||
const filename = fileURLToPath(import.meta.url)
|
const importConfigImport = await import(
|
||||||
const dirname = path.dirname(filename)
|
'../../packages/payload/dist/utilities/importWithoutClientFiles.js'
|
||||||
const url = pathToFileURL(dirname).toString() + '/'
|
)
|
||||||
|
const importConfig = importConfigImport.importConfig
|
||||||
|
|
||||||
// Need to register loader from payload/dist for a true test of functionality
|
const result = await importConfig(filePath)
|
||||||
register('../../packages/payload/dist/bin/loader/index.js', url)
|
|
||||||
|
|
||||||
const result = await import(filePath)
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user