feat(playwright): @humanjs/playwright/test — a Playwright Test fixture with a ready human#49
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
QA users currently hand-roll
createHuman(...)in every spec. This adds a Playwright Test fixture on the@humanjs/playwright/testsubpath so they don't have to:The
humanfixture is bound to the test'spageand 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:
Packaging
src/test/module → second tsup entry (dist/test.*) →./testexport.@playwright/testis an optional peer dependency (peerDependenciesMeta) — only the/testsubpath imports it; the package root stays free of the test runner.publint --strictis 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
createHumanshown as the alternative).Tests
Colocated
fixture.test.tsasserts the subpath builds and re-exports a usabletest(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
minorfor@humanjs/playwright,patchfor@humanjs/skill.