diff --git a/test/testHooks.ts b/test/testHooks.ts index 70ad8ad14..84d451f99 100644 --- a/test/testHooks.ts +++ b/test/testHooks.ts @@ -1,10 +1,11 @@ import { existsSync, promises } from 'fs' import json5 from 'json5' -import { dirname, resolve } from 'path' +import path from 'path' import { fileURLToPath } from 'url' const { readFile, writeFile, rm } = promises -const { parse } = json5 +const filename = fileURLToPath(import.meta.url) +const dirname = path.dirname(filename) type TestHooks = { afterTest: () => Promise @@ -12,13 +13,10 @@ type TestHooks = { } export const createTestHooks = async (testSuiteName = '_community'): Promise => { - const __filename = fileURLToPath(import.meta.url) - const __dirname = dirname(__filename) - console.log('\nUsing config:', testSuiteName, '\n') - const tsConfigPath = resolve(__dirname, '..', 'tsconfig.json') - const tsConfig = await parse(await readFile(tsConfigPath, 'utf8')) + const tsConfigPath = path.resolve(dirname, '..', 'tsconfig.json') + const tsConfig = await json5.parse(await readFile(tsConfigPath, 'utf8')) const originalPayloadConfigTsValue = tsConfig.compilerOptions.paths['@payload-config'] ?? './test/_community/config.ts' @@ -28,7 +26,7 @@ export const createTestHooks = async (testSuiteName = '_community'): Promise { // Delete next webpack cache - const nextWebpackCache = resolve(__dirname, '..', '.next/cache/webpack') + const nextWebpackCache = path.resolve(dirname, '..', '.next/cache/webpack') if (existsSync(nextWebpackCache)) { await rm(nextWebpackCache, { recursive: true }) } @@ -37,7 +35,7 @@ export const createTestHooks = async (testSuiteName = '_community'): Promise