Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kwangure/sitgent

Playwright test assertions in vitest
https://github.com/kwangure/sitgent

playwright svelte sveltekit testing

Last synced: 3 days ago
JSON representation

Playwright test assertions in vitest

Awesome Lists containing this project

README

        

# sitgent
An anagram of *testing*. `@playwright/test`'s assertions in Vitest.

## Usage
```javascript
import { expect } from 'vitest';
import { matchers } from 'sitgent/matchers';
import { chromium } from 'playwright';

expect.extend(matchers);

let browser, page;

beforeAll(async (context) => {
browser = await chromium.launch();

return async () => await browser.close();
});

beforeEach(async () => {
page = await browser.newPage();
});

it('is something', async () => {
const element = await page.locator('#element');

expect(element)
// Playwright assertion
.toHaveJSProperty();
// Implemented:
// .toBeChecked(...);
// .toBeDisabled(...);
// .toBeEditable(...);
// .toBeEmpty(...);
// .toBeEnabled(...);
// .toBeHidden(...);
// .toBeVisible(...);
// .toContainText(...);
// .toHaveAttribute(...);
// .toHaveClass(...);
// .toHaveCount(...);
// .toHaveCSS(...);
// .toHaveId(...);
// .toHaveJSProperty(...);
// .toHaveText(...);
// .toHaveValue(...);
// .toHaveValues(...);
// .toHaveTitle(...);
// .toHaveURL(...);
});
```

See [Playwright assertion documentation](https://playwright.dev/docs/test-assertions) for function
signatures and options.