GithubHelp home page GithubHelp logo

adeira / fixtures-tester Goto Github PK

View Code? Open in Web Editor NEW
0.0 4.0 0.0 36 KB

:books: Utility to ease testing with fixtures. This repository is automatically exported from https://github.com/adeira/universe via Shipit

License: MIT License

JavaScript 100.00%

fixtures-tester's Introduction

Install (via Yarn or NPM):

yarn add @adeira/fixtures-tester

generateTestsFromFixtures

This function loads all the fixture files (their file content) from your folder and snapshots the result of your callback operation. This is handy when you have several example files, you want to perform some operation on top of them and snapshot the results.

import { generateTestsFromFixtures } from '@adeira/fixtures-tester';

generateTestsFromFixtures(
  `${__dirname}/__fixtures__`,
  (input: string): string => {
    return doSomethingWithTheInput(input); // this result will be saved in a Jest snapshot
  },
  // optionally a snapshot name
);

There are two additional modes which allow you to control the fixtures behavior more precisely. There are based on the fixture name:

  • simpleExample.graphql - fixture will snapshot as expected
  • simpleExample.only.graphql - only these snapshots will run (for debug only)
  • simpleExample.error.graphql - it's expected that fixture will throw an error (expected to fail tests)

The error file convention is required to prevent unintentional snapshots of exceptions.

verifyTestsFromFixtures

This function simply verifies that the callback returns true but it doesn't snapshot anything:

import { verifyTestsFromFixtures } from '@adeira/fixtures-tester';

verifyTestsFromFixtures(`${__dirname}/__fixtures__`, (input: string): boolean => {
  return isInputValid(input) === true;
});

This is handy when the snapshot from generateTestsFromFixtures would be meaningless but you still want to check all available fixtures.

fixtures-tester's People

Contributors

dependabot[bot] avatar jaroslav-kubicek avatar mrtnzlml avatar renovate-bot avatar renovate[bot] avatar tbergquist-godaddy avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.