package
Easily create and maintain test fixtures in the file system
npm install fixturezGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Easily create and maintain test fixtures in the file system
yarn add --dev fixturez/path/to/project/
/src/
/fixtures/
samples.txt
examples/...
/nested/
/fixtures/
data.json
test.js// src/nested/test.js
const test = require('ava');
const fixtures = require('fixturez');
const f = fixtures(__dirname);
test('finding a fixture', t => {
let filePath = f.find('samples.txt'); // "/path/to/project/src/fixtures/samples.txt"
// ...
});
test('copying a file', t => {
let tmpPath = f.copy('data.json'); //
// "/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/a9fb0decd08179eb6cf4691568aa2018/data.json"
// (from /path/to/project/src/nested/fixtures/samples.txt)
const fixtures = require('fixturez');fixtures(dirname, opts)Create fixture functions for the current file.
const f = fixtures(__dirname);f.find(basename)Find and return the path to a fixture by its basename (directory or filename
including file extension).
let dirname = f.find('directory');
let filename = f.find('file.txt');
f.find('file'); // Error, not found!f.copy(basename)Copy a fixture into a temporary directory by its basename.
let tempDir = f.copy('directory');
let tempFile = f.copy('file.txt');f.temp()Create an empty temporary directory.
let tempDir = f.temp();f.cleanup()Deletes any temporary files you created. This will automatically be called when the Node process closes.
opts.globWhich files to match against when searching up the file system.
Default: {fixtures,__fixtures__}/*
const f = fixtures(__dirname, { glob: 'mocks/*.json' });opts.cleanupAutomatically cleanup temporary files created
Default: true
const f = fixtures(__dirname, { cleanup: false });opts.rootSet the parent directory to stop searching for fixtures.
Default: "/"
const f = fixtures(__dirname, { root: 'path/to/project' });Estimated unpacked size across 27 packages.
1.4 MB
Includes dependencies.
4 direct · 4 outdated
^0.2.1
3.2.0
^7.1.1
16.2.4
^5.0.0
11.4.1
^3.0.2
4.1.0