https://github.com/preactjs/playwright-ct
Preact adapter for Playwright Component testing
https://github.com/preactjs/playwright-ct
Last synced: 8 months ago
JSON representation
Preact adapter for Playwright Component testing
- Host: GitHub
- URL: https://github.com/preactjs/playwright-ct
- Owner: preactjs
- License: mit
- Created: 2022-10-27T22:50:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-25T13:12:24.000Z (about 2 years ago)
- Last Synced: 2024-10-29T15:32:32.343Z (over 1 year ago)
- Language: TypeScript
- Size: 64.5 KB
- Stars: 16
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Preact playwright component testing
> **Note**
> Playwright component testing is marked as experimental by the playwright team.
## Usage
First, install playwright and initialize component testing. Once that is done, install the preact adapter.
```sh
npm init playwright@latest -- --ct
npm install -D @preact/playwright-ct
```
After installing we need to alter our config
```ts
import { defineConfig } from "@preact/playwright-ct";
export default defineConfig({
// Your config
});
```
Now you can start adding your first test:
```jsx
// App.jsx
export function App() {
return
Hello World!
}
```
```jsx
// App.test.jsx
import { test, expect } from "@preact/playwright-ct";
import { App } from "./App";
test("should work", async ({ mount }) => {
const component = await mount();
await expect(component).toContainText("hello world");
});
```
Follow the offical [playwright component testing documentation](https://playwright.dev/docs/test-components) for more information on how to use it.
## License
MIT, see the [LICENSE](./LICENSE) file.