playwright: [BUG] tsconfig-loader tries to load non-existing tsconfig causing the correct config not to be used

Context:

  • 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). image

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: image

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

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (8 by maintainers)

Commits related to this issue

Most upvoted comments

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.