Closed rstoneIDBS closed 1 year ago
For most web component test cases (in my experience anyway) - you simply want to mount the web component the same way you would mount it in an app, i.e. as a string:
<my-web-component some-attribute="foo">bar</my-web-component>
This (very hacky) fix allows the above option whilst keeping the existing behaviour if necessary.
Thank you for another PR! It is nice that the component used in testing is used in the same way as in production. However the cons i see are:
If we do this, i think this should be added to Playwright first. Someone else asked the same thing for Svelte BTW.: https://github.com/microsoft/playwright/issues/18758#issuecomment-1319599376
Maybe we should create a separate issue for now to collect upvotes?
For most web component test cases (in my experience anyway) - you simply want to mount the web component the same way you would mount it in an app, i.e. as a string:
<my-web-component some-attribute="foo">bar</my-web-component>
This (very hacky) fix allows the above option whilst keeping the existing behaviour if necessary.Thank you for another PR! It is nice that the component used in testing is used in the same way as in production. However the cons i see are:
- It will destroy type safety
- It is not consistent with Playwright's API
- Would have to register the component manually as we cannot resolve the component based on a string
If we do this, i think this should be added to Playwright first. Someone else asked the same thing for Svelte BTW.: microsoft/playwright#18758 (comment)
Maybe we should create a separate issue for now to collect upvotes?
I've discovered a problem with this 'hack' anyway :) It's not un-mounting the component(s) between tests and I also have to have at least one test that creates the component via the standard mechanism otherwise it doesn't recognise any tests. So yes, probably safe to ignore this for now - however it is (IMO) a much nicer way to component test web components than creating them using JS.
For most web component test cases (in my experience anyway) - you simply want to mount the web component the same way you would mount it in an app, i.e. as a string:
<my-web-component some-attribute="foo">bar</my-web-component>
This (very hacky) fix allows the above option whilst keeping the existing behaviour if necessary.