Playwright + Jev: tests in plain language
Write Playwright steps like "add the most expensive item to the cart". Jev finds the right buttons and fields, fills forms and checks the result.
# playwright-jev
Use semantic descriptions in ordinary Playwright code. Jev selects elements and checks claims; Playwright performs the actions.
## Install
Requires Node.js 20+, Git, and an existing Playwright project with browsers installed.
```sh
npm install github:cwwmbm/playwright-jev dotenv
```
Git installation builds the package automatically, so npm install scripts must be enabled. To pin a version, append `#<commit-sha>` or an existing Git tag.
## Configure
Create `.env` in your Playwright project's root:
```dotenv
OPENROUTER_API_KEY=your-openrouter-api-key
# Optional; this is the default model:
OPENROUTER_MODEL=typesafe/jev-1.13
```
Add `.env` to `.gitignore`. Load it from your `playwright.config.ts`:
```ts
import 'dotenv/config';
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: './tests',
});
```
The library reads environment variables but does not load `.env` itself. For standalone scripts, add `import 'dotenv/config'` to the script instead. Live decisions use your OpenRouter account and incur API charges.
## Quick start
```ts
import { test } from '@playwright/test';
import { createJev } from 'playwright-jev';
test('add the most expensive product', async ({ page }) => {
const jev = createJev(page);
await page.goto('https://www.saucedemo.com/');
await jev.fill('username', 'standard_user');
await jev.fill('password', 'secret_sauce');
await jev.click('log in');
const item = await jev.read('the name of the most expensive item');
await jev.click('add to cart on the most expensive item');
await jev.click('go to shopping cart');
await jev.verify('the cart contains exactly one item named expectedItem', {
expectedItem: item,
});
});
```
Run with `npx playwright test`, or add `--headed`