Show HN: Runner-agnostic typed test fixtures inspired by Playwright

https://www.npmjs.com/package/fixtures-ts
by mrded • 5 months ago
1 0 5 months ago

I really like the fixture model in Vitest and Playwright - typed, composable, dependency-based setup with automatic ordering and teardown.

That pattern is powerful, but it’s tightly coupled to those runners. I wanted the same model in bun:test and across projects using different test frameworks.

So I built a small runner-agnostic fixture system in TypeScript inspired by that approach.

It lets you:

- define fixtures with explicit dependencies

- request only what a test needs

- resolve setup order automatically

- deduplicate shared fixtures

- run cleanup in reverse order

- detect circular dependencies

It’s intentionally small and framework-agnostic.

I’d really appreciate feedback on the API design and whether this pattern makes sense outside Vitest/Playwright.

Related Stories

Loading related stories...

Source preview

npmjs.com