This repository was archived by the owner on Sep 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-18
lines changed Expand file tree Collapse file tree 1 file changed +10
-18
lines changed Original file line number Diff line number Diff line change @@ -198,30 +198,22 @@ export const readConfig = async (
198
198
if ( jestEnvConfig ) {
199
199
return deepMerge < JestPlaywrightConfig > ( DEFAULT_CONFIG , jestEnvConfig )
200
200
}
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'
206
203
const configPath =
207
- process . env . JEST_PLAYWRIGHT_CONFIG ||
204
+ JEST_PLAYWRIGHT_CONFIG ||
208
205
`${ CONFIG_ENVIRONMENT_NAME } .config.${ fileExtension } `
209
206
const absConfigPath = path . resolve ( rootDir , configPath )
210
- let configExists = true
211
207
try {
212
208
await fsPromises . access ( absConfigPath )
213
209
} 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
+ }
225
217
}
226
218
227
219
const localConfig = await require ( absConfigPath )
You can’t perform that action at this time.
0 commit comments