Skip to content

feat(playwright): @humanjs/playwright/test — a Playwright Test fixture with a ready human#49

Merged
totigm merged 4 commits into
mainfrom
feat/test-fixture
Jun 2, 2026
Merged

feat(playwright): @humanjs/playwright/test — a Playwright Test fixture with a ready human#49
totigm merged 4 commits into
mainfrom
feat/test-fixture

Conversation

@totigm

@totigm totigm commented Jun 2, 2026

Copy link
Copy Markdown
Owner

What & why

QA users currently hand-roll createHuman(...) in every spec. This adds a Playwright Test fixture on the @humanjs/playwright/test subpath so they don't have to:

import { test, expect } from '@humanjs/playwright/test';

test('checkout', async ({ human, page }) => {
  await human.goto('/cart');
  await human.click('Checkout');
  await expect(page).toHaveURL(/success/);
});

The human fixture is bound to the test's page and defaults to seed = the test title (deterministic per test) and speed = instant in CI / humanized locally — the pattern we already document, now automatic.

Customize per file or per project:

test.use({ humanOptions: { personality: 'distracted', speed: 'human' } });

Packaging

  • New src/test/ module → second tsup entry (dist/test.*) → ./test export.
  • @playwright/test is an optional peer dependency (peerDependenciesMeta) — only the /test subpath imports it; the package root stays free of the test runner. publint --strict is clean and the subpath resolves correctly from a consumer (dist/test.cjs).

Docs

Root README "In tests", the package README, and the skill's CI/determinism section now lead with the fixture (explicit createHuman shown as the alternative).

Tests

Colocated fixture.test.ts asserts the subpath builds and re-exports a usable test (with .extend/.use) + expect — the runtime fixture behavior (seed/CI) is exercised by Playwright Test itself, not vitest. Gate green: lint · typecheck 9/9 · tests 8/8 · build 6/6 · check:exports (publint) 11/11.

Changeset

minor for @humanjs/playwright, patch for @humanjs/skill.

A Playwright Test subpath that extends `test` with a `human` fixture —
bound to the test's page, seeded from the test title, instant in CI /
humanized locally — so specs skip the createHuman boilerplate. Customize
via test.use({ humanOptions: { ... } }).

@playwright/test is an optional peer (only the /test subpath needs it; the
package root is untouched). Adds a second tsup entry + the ./test export;
publint --strict clean. Docs updated in the root README, package README,
and the skill.
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
humanjs Ready Ready Preview, Comment Jun 2, 2026 5:11pm

The standalone-bundled /test entry inlined a full copy of the library
(createHuman + deps), ~64K per format. Enabling tsup `splitting` extracts
the shared code into a chunk both entries import: test.js 64K -> ~650B,
test.cjs 64K -> ~760B, one shared chunk per format. publint --strict
clean; both entries resolve + load from a consumer.
The /test fixture bridges @playwright/test's Page into createHuman (which
types Page from playwright). Pinning only playwright left @playwright/test
at 1.60, so two playwright-core versions coexisted and their Page types
diverged. Real installs always match the two; pin both to the matrix
version so the job mirrors that.
toPlaywright() now emits `import { test, expect } from
'@humanjs/playwright/test'` + `test.use({ humanOptions })` (carrying the
recorded personality/seed/speed) instead of a per-test createHuman call —
shorter generated tests that dogfood the new fixture. `page` is only in
the test args when an assertion uses it. toHumanJS() (standalone script)
is unchanged. codegen tests updated.
@totigm totigm merged commit 54b3c65 into main Jun 2, 2026
6 checks passed
@totigm totigm deleted the feat/test-fixture branch June 2, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant