Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example in monorepo works, can't get it too work on my own project or clean vite install. #38

Closed
herrKlein opened this issue Jan 28, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@herrKlein
Copy link

Would love to use this to unit test my lit components.

I first tried it on my own project by initializing this
npm init playwright-sand4rt@latest -- --ct

I create the example Button.ts and Button.test.ts,
first error was:
Error: Unsupported decorator location: field
Solved this by adding accessor

  @property({ type: String })
  -title!: string;
  +accessor title!: string;

It compiled, but next was this error:

Error: TypeError: Cannot read properties of undefined (reading 'toUpperCase')
at __pwResolveComponent (http://localhost:3100/assets/index-8c01864d.js:199:46)

I then downloaded playwright-ct-web to test the ct-web-lit exampled.
This ran correctly inside the monorepo
I tried moving the ct-web-lit outside the monorep,
replaced this line:

-"@sand4rt/experimental-ct-web": "workspace:*",
+"@sand4rt/experimental-ct-web": "^1.41.0",

To have a standalone working version, this failed due to this error:

Screenshot 2024-01-28 at 11 33 54

I also created a clean vite-lit repo, installed your testing lib:
npm init playwright-sand4rt@latest -- --ct
Copied the button example and test of the readme, got almost the same error:
Screenshot 2024-01-28 at 11 40 42

I would really like this to work, to unit test my lit components in playwright.

Could you shed some light why your ct-web-lit is working in the monorepo, but I can't get any test to work with the initialize

@herrKlein herrKlein added the bug Something isn't working label Jan 28, 2024
@sand4rt
Copy link
Owner

sand4rt commented Jan 29, 2024

Hi @herrKlein, thanks for reporting. I'll look into it.

Does an older version of the lib work?

@herrKlein
Copy link
Author

I tried it with version 39.0. Produces the same error.
It seems its something with rendering the react component. Trying to figure out why the monorepo version works and my clean vite install isn't?

@fajar-apri-alaska
Copy link

+1
Leaving my trace here because I also have the exact same issue.

@sand4rt
Copy link
Owner

sand4rt commented Feb 19, 2024

A temporary workaround is to give the components which are imported in a test file a suffix e.g., change Button.ts to Button.component.ts.

This issue has to be resolved first:
microsoft/playwright#29544

@sand4rt
Copy link
Owner

sand4rt commented May 8, 2024

Should be fixed in the latest version. Feel free to create a new issue otherwise

@sand4rt sand4rt closed this as completed May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants