Giter VIP home page Giter VIP logo

chai-baseline's Introduction

File-based baseline testing for chai.

chai-baseline adds simplified file-based baseline testing for chai. With it you can compare data to a reference file on disk, storing a local file in the process. This allows for the use of large-scale diff tools to do additional comparisons outside of the tests themselves.

Installation

npm install chai-baseline

Usage

chai-baseline can only be used in NodeJS where it has access to the file system.

Usage with expect

// ES6 syntax (TypeScript, Babel)
import { use, expect } from "chai";
import chaiBaseline from "chai-baseline";
use(chaiBaseline);

// pre-ES6 syntax
var chai = require("chai"), expect = chai.expect;
var chaiBaseline = require("chai-baseline").default;
chai.use(chaiBaseline);

// usage
it("baseline", () => {
    const text = "...output text...";
    return expect(text).to.have.baseline("transpilerOutput.txt", { base: "./baselines" }); // returns Promise
});

Usage with assert

// ES6 syntax (TypeScript, Babel)
import { use, assert } from "chai";
import chaiBaseline from "chai-baseline";
use(chaiBaseline);

// pre-ES6 syntax
var chai = require("chai"), assert = chai.assert;
var chaiBaseline = require("chai-baseline").default;
chai.use(chaiBaseline);

// usage
it("baseline", () => {
    const text = "...output text...";
    return assert.baseline(text, "transpilerOutput.txt", { base: "./baselines" }); // returns Promise
});

chai-baseline's People

Contributors

rbuckton avatar

Watchers

 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.