playwright: [BUG] Can't use component testing in existing project
Context:
- Playwright Version: 1.26.1
- Operating System: Mac
- Node.js version: 16.13.0
- Browser: All
CodeSandbox link showing bug (running below repo): https://github.com/piotrpalek/playwright-issue Github link to example repo: https://github.com/piotrpalek/template-hcp/tree/playwright
The error
Error: Cannot find module '/project/template-hcp/spec/javascripts/utils/apiMock' imported from /project/template-hcp/src/App.pw.tsx
Describe the bug
Hey, I’m trying to run playwright, on an existing webpack project, but I’m getting an issue when trying to import modules without adding a file extension. It’s saying “Error: Cannot find module” when trying to run it. I’ve succeeded in making an example repo showing the exact same issue.
It would be pretty cumbersome (and against our current styleguide) to change all imports to have file extensions. Is there a workaround I could use here?
Extra
After some initial debugging I’ve found that at this point (filename.endsWith...), playwright throws an error, it’s just getting swallowed along the way. The error that it’s throwing is:
'Cannot read properties of null (reading 'endsWith')'
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (11 by maintainers)
Commits related to this issue
- chore: respect tsconfig paths in js files (#18191) Fixes: https://github.com/microsoft/playwright/issues/17804 — committed to microsoft/playwright by pavelfeldman 2 years ago
Oh, you updated the link for CodeSandbox, I was using the second one. I can reproduce it with https://github.com/piotrpalek/playwright-issue