npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fixture-interface

v1.1.1

Published

A simple interface to make helpers for setting up and tearing down data needed for tests.

Downloads

2

Readme

fixture-interface

A JavaScript test fixture library that provides a simple interface for managing test data lifecycle across different storage backends.

Summary

This library solves the common testing problem of setting up and cleaning up test data. It provides a consistent interface for provisioning test data before tests run and automatically cleaning it up afterward, preventing test pollution and ensuring reliable test execution across different data stores.

How it works

Core Purpose:

  • Setup: Bulk insert test data before tests run using the provision() method
  • Cleanup: Automatically remove all test data after tests complete using the cleanup() method
  • Track: Keep track of data created during test execution using the addData() method

Key Benefits:

  • Prevents test pollution by ensuring clean data state between tests
  • Supports different data stores (memory, DynamoDB, etc.) through inheritance
  • Uses deep cloning to prevent accidental data modification
  • Promise-based for async operations

Installation

npm install fixture-interface

Module Support

This package supports both CommonJS and ESM (ES Modules). Node.js will automatically use the appropriate version based on your project setup.

TypeScript Support

This package includes TypeScript declaration files (.d.ts) for full type safety and IntelliSense support in TypeScript projects.

Example Usage

1. Create a base fixture for your data store

CommonJS:

// base-fixtures/memory.fx.js
const Fixture = require('fixture-interface');
const memoryStore = require('../data-store/memory');

class MemoryFixture extends Fixture {
  insert(item) {
    memoryStore[item.id] = item;
    return Promise.resolve();
  }

  remove(item) {
    delete memoryStore[item.id];
    return Promise.resolve();
  }
}

module.exports = MemoryFixture;

ESM:

// base-fixtures/memory.fx.js
import Fixture from 'fixture-interface';
import memoryStore from '../data-store/memory.js';

class MemoryFixture extends Fixture {
  insert(item) {
    memoryStore[item.id] = item;
    return Promise.resolve();
  }

  remove(item) {
    delete memoryStore[item.id];
    return Promise.resolve();
  }
}

export default MemoryFixture;

2. Create domain-specific fixtures

CommonJS:

// fixtures/car.fx.js
const MemoryFixture = require('../base-fixtures/memory.fx');

class CarFixture extends MemoryFixture {
  insert(item) {
    // Add domain-specific logic
    item.hash_key = `${item.year};${item.make};${item.model}`;
    return super.insert(item);
  }

  remove(item) {
    return super.remove({id: item.hash_key});
  }
}

module.exports = CarFixture;

ESM:

// fixtures/car.fx.js
import MemoryFixture from '../base-fixtures/memory.fx.js';

class CarFixture extends MemoryFixture {
  insert(item) {
    // Add domain-specific logic
    item.hash_key = `${item.year};${item.make};${item.model}`;
    return super.insert(item);
  }

  remove(item) {
    return super.remove({id: item.hash_key});
  }
}

export default CarFixture;

3. Use in your tests

CommonJS:

// test.spec.js
const CarFixture = require('./fixtures/car.fx');
const testData = require('./fixture-data/cars.json');

describe('Car tests', () => {
  let carFixture;

  beforeEach(async () => {
    carFixture = new CarFixture();
    await carFixture.provision(testData); // Sets up all test data
  });

  afterEach(async () => {
    await carFixture.cleanup(); // Removes all test data
  });

  it('should find cars by make', () => {
    // Your test logic here - data is already provisioned
  });
});

ESM:

// test.spec.js
import CarFixture from './fixtures/car.fx.js';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const testData = JSON.parse(readFileSync(join(__dirname, './fixture-data/cars.json'), 'utf8'));

describe('Car tests', () => {
  let carFixture;

  beforeEach(async () => {
    carFixture = new CarFixture();
    await carFixture.provision(testData); // Sets up all test data
  });

  afterEach(async () => {
    await carFixture.cleanup(); // Removes all test data
  });

  it('should find cars by make', () => {
    // Your test logic here - data is already provisioned
  });
});

4. Test data format

// fixture-data/cars.json
[
  {
    "year": 2000,
    "make": "Pontiac", 
    "model": "Grand Prix",
    "reviews": [
      {
        "author": "Rick Sanchez",
        "rating": 5,
        "review": "Great car!"
      }
    ]
  }
]

The fixture will provision this data before each test and clean it up afterward, ensuring each test starts with a known data state.