New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fixtures-ts

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fixtures-ts

Type-safe test fixtures for Jest, Vitest, Bun, and Mocha. Automatic dependency resolution and cleanup with Playwright-style API

latest
Source
npmnpm
Version
0.1.4
Version published
Maintainers
1
Created
Source

fixtures-ts

Type-safe test fixture management with automatic dependency resolution for any test framework.

Installation

npm install fixtures-ts

Quick Start

import {
  createFixtures,
  defineFixture,
  type FixtureRegistry,
} from "fixtures-ts";

type Fixtures = {
  db: Database;
  client: TestClient;
};

const registry: FixtureRegistry<Fixtures> = {
  db: defineFixture<Fixtures, [], Fixtures["db"]>([], async () => ({
    value: await createTestDatabase(),
    cleanup: async () => await closeDatabase(),
  })),

  client: defineFixture<Fixtures, ["db"], Fixtures["client"]>(
    ["db"],
    async ({ db }) => ({
      value: createTestClient(db),
      cleanup: async () => {},
    }),
  ),
};

const fixtures = createFixtures(registry, ["client"]);

beforeEach(fixtures.setup);
afterEach(fixtures.teardown);

test("should work", async () => {
  const { client } = fixtures.get();
  // use client...
});

Note: The defineFixture() API is intentionally verbose to provide maximum type safety. I'm aware of this and exploring ways to simplify the fixture definition syntax while maintaining type safety. For now, the current approach works reliably and provides excellent TypeScript inference.

Documentation

📖 Full Documentation

Features

  • ✅ Automatic dependency resolution
  • ✅ Type-safe with full TypeScript support
  • ✅ Automatic cleanup in reverse order
  • ✅ Circular dependency detection
  • ✅ Framework agnostic (works with any test runner)

Sponsors

License

MIT

Keywords

test

FAQs

Package last updated on 02 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts