@preact/playwright-ct
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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.

npm init playwright@latest -- --ct
npm install -D @preact/playwright-ct

After installing we need to alter our config

import { PlaywrightTestConfig } from "@preact/playwright-ct";

const config: PlaywrightTestConfig = {
  // Your config
};

export default config;

Now you can start adding your first test:

// App.jsx
export function App() {
  return <h1>Hello World!</h1>
}
// App.test.jsx
import { test, expect } from "@preact/playwright-ct";
import { App } from "./App";

test("should work", async ({ mount }) => {
  const component = await mount(<App />);
  await expect(component).toContainText("hello world");
});

Follow the offical playwright component testing documentation for more information on how to use it.

License

MIT, see the LICENSE file.

Package Sidebar

Install

npm i @preact/playwright-ct

Weekly Downloads

30

Version

0.1.1

License

MIT

Unpacked Size

9.41 kB

Total Files

11

Last publish

Collaborators

  • rschristian
  • drewigg
  • reznord
  • preactjs
  • developit
  • marvinhagemeister
  • jdecroock
  • sventschui