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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ava-fixture

v0.11.0

Published

Write fixture tests with ava

Downloads

112

Readme

ava-fixture

stable NPM version NPM downloads Build status Coverage Status

This library helps you to write fixture tests: test-per-folder or test-per-file.

Usage

For example, you are testing code that process files (e.g. a compiler, config-reader, etc).

You put each test case inside its own folder:

+ fixtures
  + cases
    + empty
      - somefiles
    + basic-case
      - someOtherFiles
    + single-line
      - ...
    + ...

You can run each test case like this:

import ava from 'ava';
import fixture from 'ava-fixture';

// Point to the base folder which contain the fixtures.
// Use relative path starts from project root or absolute path
const ftest = fixture(ava, 'fixtures/cases', 'fixtures/baselines', 'fixtures/results');

ftest.each((t, d) => {
  // d.caseName: 'empty', 'basic-case', 'single-line', etc
  // d.casePath: absolute path points to each test case folder
  // d.resultPath: absolute path points to each test result folder

  // Your test target reads from `d.casePath` and writes to `d.resultPath`
  target.process(d.casePath, d.resultPath)

  // d.match() will compare the result folder against the baseline folder
  return d.match()
})

You can also use this library to run tests that only read files:

import ava from 'ava';
import fixture from 'ava-fixture';

// Point to the base folder which contain the fixtures.
// Relative path starts from project root.
const ftest = fixture(ava, 'fixture/cases');

ftest('test title', 'case-1', (t, d) => {
  // t is ava test assertion.
  t.is(d.casePath, 'absolut path the the case folder')

  const result = target.read(d.casePath)

  t.deepEqual(result, 'expected result')
});

// test title can be omitted
ftest('case-1', (t, d) => {
  // ...
})

// go through each test
ftest.each((t, d) => {
  // ...
})

// or run certain test based on filter
ftest.each(/some filter/, (t, d) => {
  // ...
})

Other API

import test from 'ava';
import fixture from 'ava-fixture';

const ftest = fixture(test, 'fixture/cases');

ftest.only(...)
ftest.skip(...)
ftest.failing(...)
ftest.only.each.failing(...)

For before(), beforeEach(), after(), afterEach(), todo(), use ava directly.

Contribute

# right after clone
npm install

# begin making changes
git checkout -b <branch>
npm run watch

# edit `webpack.config.es5.js` and `rollup.config.es2015.js` to exclude dependencies for the bundle if needed

# after making change(s)
git commit -m "<commit message>"
git push

# create PR

Npm Commands

There are a few useful commands you can use during development.

# Run tests (and lint) automatically whenever you save a file.
npm run watch

# Run tests with coverage stats (but won't fail you if coverage does not meet criteria)
npm run test

# Manually verify the project.
# This will be ran during 'npm preversion' so you normally don't need to run this yourself.
npm run verify

# Build the project.
# You normally don't need to do this.
npm run build

# Run tslint
# You normally don't need to do this as `npm run watch` and `npm version` will automatically run lint for you.
npm run lint

Generated by generator-unional@0.9.0