question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Can't use component testing in existing project

See original GitHub issue

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')'

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
yury-scommented, Oct 5, 2022

@yury-s that’s weird I just tried the repo from scratch and yarn run test-ct works. Did you clone it from scratch? I’ve changed the link to point to a fresh repo to make sure.

Oh, you updated the link for CodeSandbox, I was using the second one. I can reproduce it with https://github.com/piotrpalek/playwright-issue

0reactions
pavelfeldmancommented, Oct 17, 2022

I think we are on the same page now.

In terms of actionability on this bug, configuring aliases is somewhat a mess in the Node land: different bundlers will use different config files for that, they won’t respect the tsconfig’s ones. In the end every framework ends up introducing its own config. Here is an example. Our options would be to:

  • A: introduce aliases in our config
  • B: respect aliases from tsconfig for JS files
  • C: do both: introduce aliases and fall back to tsconfig if there is any

I don’t think we should do B since it is puling JS people into the TS land for just that feature. So it would need to be something like C.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can unit testing be successfully added into an existing ...
I've introduced unit tests to code bases that did not have it previously. The last big project I was involved with where I...
Read more >
9 techniques for fixing bugs in production - TechTarget
Prioritize test code​​ Maintain test code as carefully as project code, and always write unit tests for any change developers make. It's ...
Read more >
Tests Cant Prove The Absence Of Bugs - C2 wiki
So, while testing cannot prove the absence of bugs it can prove their existence - and this is an important and good thing....
Read more >
What is Component Testing Or Module Testing (Learn With ...
Component Testing is done by QA services or the tester. What is tested under component Testing? Component testing may take account of verifying ......
Read more >
Cannot enable Unit testing | Apple Developer Forums
Since my project uses CocoaPods (and there are multiple issues there alone) I tried to isolate the problem with a test project that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found