[BUG] tsconfig-loader tries to load non-existing tsconfig causing the correct config not to be used
See original GitHub issueContext:
- Playwright Version: 1.23.1
- Operating System: Windows 10 x64
- Node.js version: 16.17.0
- Browser: All
- Extra: [any specific details about your environment]
Code Snippet
import { Environment } from '@oas/internal-lib-e2e';
Describe the bug
I’m unable to import my monorepo package using TypeScript paths in the runner’s child process (it works in the main process).

After a debugging session with myself here: https://github.com/microsoft/playwright/discussions/17466, i have come to the conclusion that the tsconfig-loader (https://github.com/microsoft/playwright/blob/29ff00ead2e79ea9b5374513f98801745e93b80c/packages/playwright-test/src/third_party/tsconfig-loader.ts#L60) is trying to resolve a tsconfig that doesn’t exists and then try to use that instead of the correct one in the package root (process.cwd() in the main process).
So here it is resolving a non-existent tsconfig file:

And then it’s using that in the child process instead of the correct one with the paths:

Since the cwd for the child process is the testDir from the config file, and not the package root, no matter what I do, I will have to wrong path since I use ./tsconfig.json as TS_NODE_PROJECT. It will always be resolved to the wrong path.
My guess is that you do not want to return a non-existent tsconfig.json or return it but then don’t cache it in loadAndValidateTsconfigForFile here: https://github.com/microsoft/playwright/blob/42491ecc0867129b97fa2fbd4fe9c58ff0d3feff/packages/playwright-test/src/transform.ts#L79
Issue Analytics
- State:
- Created a year ago
- Comments:18 (8 by maintainers)

Top Related StackOverflow Question
When resolving config for the TypeScript file, resolution is based on the filesystem nesting, so I’m not sure why cwd is used. We are inheriting this logic from tsloader, so we should have probably cleaned it up further.
I discussed this issue with the team and we arrived to the following:
ts-nodesemantics.tsconfig.jsonin thetestsdirectory for any test-specific path mappings.Overall, Playwright assumes that each file is either:
If you have a question or need help with your setup, please share your repro and we’ll try to help as we can. If you believe there is still a problem, please file a new issue with a repro and link to this one.