Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit f1665b4

Browse files
authored
Update utils.ts (#622)
1 parent ffd6a5c commit f1665b4

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

src/utils.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -198,30 +198,22 @@ export const readConfig = async (
198198
if (jestEnvConfig) {
199199
return deepMerge<JestPlaywrightConfig>(DEFAULT_CONFIG, jestEnvConfig)
200200
}
201-
const hasCustomConfigPath = !!process.env.JEST_PLAYWRIGHT_CONFIG
202-
let fileExtension = 'js'
203-
if (process.env.npm_package_type === 'module') {
204-
fileExtension = 'cjs'
205-
}
201+
const { JEST_PLAYWRIGHT_CONFIG, npm_package_type } = process.env
202+
const fileExtension = npm_package_type === 'module' ? 'cjs' : 'js'
206203
const configPath =
207-
process.env.JEST_PLAYWRIGHT_CONFIG ||
204+
JEST_PLAYWRIGHT_CONFIG ||
208205
`${CONFIG_ENVIRONMENT_NAME}.config.${fileExtension}`
209206
const absConfigPath = path.resolve(rootDir, configPath)
210-
let configExists = true
211207
try {
212208
await fsPromises.access(absConfigPath)
213209
} catch (e) {
214-
configExists = false
215-
}
216-
217-
if (hasCustomConfigPath && !configExists) {
218-
throw new PlaywrightError(
219-
`Can't find a root directory while resolving a config file path.\nProvided path to resolve: ${configPath}`,
220-
)
221-
}
222-
223-
if (!hasCustomConfigPath && !configExists) {
224-
return DEFAULT_CONFIG
210+
if (JEST_PLAYWRIGHT_CONFIG) {
211+
throw new PlaywrightError(
212+
`Can't find a root directory while resolving a config file path.\nProvided path to resolve: ${configPath}`,
213+
)
214+
} else {
215+
return DEFAULT_CONFIG
216+
}
225217
}
226218

227219
const localConfig = await require(absConfigPath)

0 commit comments

Comments
 (0)