The idea comes from @tannerlinsley: https://youtu.be/DXbfDKoMzWY?t=1467.
// ./playwright/index.tsx
import { beforeMount } from '@playwright/experimental-ct-solid/hooks';
// Override HooksConfig so there is no need to specify it as a `mount<HooksConfig>` generic
declare module '@playwright/experimental-ct-solid/hooks' {
interface RegisterHooksConfig {
route: string;
}
}
beforeMount(async ({ hooksConfig }) => {
hooksConfig.DOES_NOT_EXSISTS; // throws an error without specifying the generic
});
// App.test.tsx
import { expect, test } from "@playwright/experimental-ct-solid";
import { App } from "./app";
test('type check', async ({ mount }) => {
const component = await mount(<App />, {
hooksConfig: { route: '' } // is typesafe without specifying the `mount<HooksConfig>` generic
});
await expect(component.getByText('label')).toBeVisible();
});
related: #18616
The idea comes from @tannerlinsley: https://youtu.be/DXbfDKoMzWY?t=1467.
related: #18616