All Projects → jamiebuilds → fixturez

jamiebuilds / fixturez

Licence: MIT license
Easily create and maintain test fixtures in the file system

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to fixturez

titef
🌠 A tiny, lightning-fast, zero-dependecies JavaScript test framework 🌠
Stars: ✭ 19 (-66.67%)
Mutual labels:  mocha, test, ava
Enzyme
JavaScript Testing utilities for React
Stars: ✭ 19,781 (+34603.51%)
Mutual labels:  mocha, test, ava
Snap Shot It
Smarter snapshot utility for Mocha and BDD test runners + data-driven testing!
Stars: ✭ 138 (+142.11%)
Mutual labels:  mocha, test
Redux Saga Testing
A no-brainer way of testing your Sagas
Stars: ✭ 150 (+163.16%)
Mutual labels:  mocha, ava
jest-fixtures
Use file system fixtures in Jest
Stars: ✭ 39 (-31.58%)
Mutual labels:  fixtures, test
Should Enzyme
Useful functions for testing React Components with Enzyme.
Stars: ✭ 41 (-28.07%)
Mutual labels:  mocha, test
Suman
🌇 🌆 🌉 Advanced, user-friendly, language-agnostic, super-high-performance test runner. http://sumanjs.org
Stars: ✭ 57 (+0%)
Mutual labels:  mocha, ava
Mocha.parallel
Run async mocha specs in parallel
Stars: ✭ 194 (+240.35%)
Mutual labels:  mocha, test
Public
Repository for wallaby.js questions and issues
Stars: ✭ 662 (+1061.4%)
Mutual labels:  mocha, ava
ts-snippet
A TypeScript snippet compiler for any test framework
Stars: ✭ 29 (-49.12%)
Mutual labels:  mocha, ava
mockingbird
🐦 Decorator Powered TypeScript Library for Creating Mocks
Stars: ✭ 70 (+22.81%)
Mutual labels:  fixtures, test
playwright-test
Run unit tests with several runners or benchmark inside real browsers with playwright.
Stars: ✭ 81 (+42.11%)
Mutual labels:  mocha, test
Chakram
REST API test framework. BDD and exploits promises
Stars: ✭ 912 (+1500%)
Mutual labels:  mocha, test
Webdriverio
Next-gen browser and mobile automation test framework for Node.js
Stars: ✭ 7,214 (+12556.14%)
Mutual labels:  mocha, test
Javascript Testing Best Practices
📗🌐 🚢 Comprehensive and exhaustive JavaScript & Node.js testing best practices (August 2021)
Stars: ✭ 13,976 (+24419.3%)
Mutual labels:  mocha, test
Jest Codemods
Codemods for migrating to Jest https://github.com/facebook/jest 👾
Stars: ✭ 731 (+1182.46%)
Mutual labels:  mocha, ava
Snap Shot
Jest-like snapshot feature for the rest of us, works magically by finding the right caller function
Stars: ✭ 170 (+198.25%)
Mutual labels:  mocha, test
Mocha
☕️ simple, flexible, fun javascript test framework for node.js & the browser
Stars: ✭ 20,986 (+36717.54%)
Mutual labels:  mocha, test
Istanbuljs
monorepo containing the various nuts and bolts that facilitate istanbul.js test instrumentation
Stars: ✭ 656 (+1050.88%)
Mutual labels:  mocha, ava
Foundry
A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.
Stars: ✭ 216 (+278.95%)
Mutual labels:  fixtures, test

fixturez

Easily create and maintain test fixtures in the file system

  • Place fixtures in any parent directory
  • Find them again in your tests by their name
  • Searches up the file system to find a match
  • Makes it easy to move fixtures around and share between tests
  • Copy them into a temporary directory
  • Automatically cleanup any temporary files created

Install

yarn add --dev fixturez

Example

/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)
});

test('copying a directory', t => {
  let tmpPath = f.copy('examples');
  // "/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/4f504b9edb5ba0e89451617bf9f971dd/examples"
  // (from /path/to/project/src/fixtures/examples)
});

API

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.glob

Which files to match against when searching up the file system.

Default: {fixtures,__fixtures__}/*

const f = fixtures(__dirname, { glob: 'mocks/*.json' });

opts.cleanup

Automatically cleanup temporary files created

Default: true

const f = fixtures(__dirname, { cleanup: false });

opts.root

Set the parent directory to stop searching for fixtures.

Default: "/"

const f = fixtures(__dirname, { root: 'path/to/project' });
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].