-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Idea/Feature: provide more powerful way to create test cases (mount) #14
Comments
Hi, does the slot API cover your case?: https://github.com/sand4rt/playwright-ct-web/blob/master/ct-web-lit/tests/slots.spec.ts test('render a component as slot', async ({ mount }) => {
const component = await mount(Form, {
slots: {
default: '<button-component title="Submit" />', // component is registered globally in /playwright/index.ts
},
});
await expect(component).toContainText('Submit');
}); |
I am more looking to utilize the full potential of lit-html. For example: maybe I want to test a custom directive:
|
@davidkron i'm hesitant to add the Do you have more use cases that are not supported but are with the |
I would say that the 6 primary use cases that the lit template syntax supports are succinctly described in the first table on the page https://lit.dev/docs/templates/expressions/ Of course the event binding syntax is pretty popular in lit, but I am not sure if something like this would be even possible to support. Because as I understand, in Playwright the testing code is run in the Node context and the rendered component is run in the browser context. |
Thanks for your reply.
*https://lit.dev/docs/templates/expressions I will look into directive support, but i don't see a good reason to deviate from Playwright's API. |
It's a bit hacky but as a get around you can do stuff like this @davidkron:
|
I am currently searching for and experimenting with alternatives to
@web/test-runner
and@open-oc/testing
for testing custom components and also stumbled overplaywright-ct
and your library. For simple use cases it seems to work well, but I have created some tests already with@web/test-runner
, which I fail to rewrite usingmount
.For example one of the problems is, that
mount
seems to only work for creating single component instances:This only works for the very simplest of use-cases. A more real-world usage (especially in the example of testing a custom button component) would be something like this, where not only the component itself, but maybe some wrapper element or children are necessary to construct a realistic test case:
I was wondering if it was possible to make
mount
more powerful and provide something similar to thefixtures
helper from https://www.npmjs.com/package/@open-wc/testing-helpers#user-content-test-a-custom-element-with-properties? Even better if one could (optionally) provide a template usinglit-html
to write better readable test cases.The text was updated successfully, but these errors were encountered: