New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fixture-compare

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fixture-compare

Compare test fixtures with each other, with strings, and against the results of transforms.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

fixture-compare

Compare test fixtures with each other, with strings, and against the results of transforms.

Build Status v1.1.0

Compare a String to a Fixture

import {inputMatchesFile} from 'fixture-compare';
const input = 'some string';
const fixture = 'result.txt'
inputMatchesFile(input, fixture);

Run a Fixture Through a Transform

Loads a fixture, runs it through a transform, then compares the results to a fixture with the same name, appended with .output.

import fixtureCompare from 'fixture-compare';
const fixture = 'test-1';
const transform = (text) => text.split('').reverse();
fixtureCompare(fixture, transform);

Run a Fixture Through a Transform, Specify Result Fixture

Same as the previous example, but allows you to specify a different output file.

import fixtureCompare from 'fixture-compare';
const input = 'test-2';
const output = 'test-2.result';
const transform = (text) => text.split('').reverse();
fixtureCompare(input, transform, output);

Specify Fixtures Directory

By default, paths to fixtures are assumed to be relative to {cwd}/test/fixtures. To specify another directory...

import {setFixturesDir} from 'fixture-compare';
setFixturesDir(path.join(__dirname, 'somewhere/else'));

Log Differences

To log differences when fixtures do not match, use setLogging.

import {setLogging} from 'fixture-compare';
setLogging(true);
- expected
+ actual

-  \n
  "||"
+  \n

     snett    ik eltt   il\n
  "++---||++++|----||+++--||"
   li   ttle ki    ttens  \n

kickstarted by npm-boom

Keywords

test

FAQs

Package last updated on 27 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts