GithubHelp home page GithubHelp logo

bahmutov / snap-shot Goto Github PK

View Code? Open in Web Editor NEW
169.0 2.0 3.0 205 KB

Jest-like snapshot feature for the rest of us, works magically by finding the right caller function

JavaScript 93.45% HTML 0.41% Shell 6.15%
test jest unit-testing snapshot mocha vue react jsx

snap-shot's Introduction

snap-shot

Jest-like snapshot feature for the rest of us + data-driven testing!

deprecated please use snap-shot-it - it grabs test instance at runtime, avoiding looking at the source code and getting lost in the transpiled code.

NPM

Build status semantic-release js-standard-style

status snap-shot-jest-test - for testing snap-shot against Jest runner (React + JSX)

status snap-shot-modules-test - for testing against transpiled ES6 modules

status snap-shot-vue-test - for testing snap-shot inside Jest + Vue.js project

status snap-shot-jsdom-test - for testing snap-shot using mock DOM adapter and element serialization

status snap-shot-ava-test - for testing how snap-shot works with Ava test framework

Why

Read Snapshot testing the hard way

I like Jest snapshot idea and want it without the rest of Jest testing framework. This module is JUST a single assertion method to be used in BDD frameworks (Mocha, Jasmine)

Also, I really really really wanted to keep API as simple and as "smart" as possible. Thus snap-shot tries to find the surrounding unit test name by inspecting its call site (using stack-sites or callsites) and parsing AST of the spec file (using falafel).

Snapshot values are compared using variable-diff (objects) and disparity (multi line strings). See images/README.md for screenshots.

This function also includes data-driven testing mode, similar to sazerac, see Data-driven testing section below.

Example

Install: npm install --save-dev snap-shot

const snapshot = require('snap-shot')
// in ES6 code use
import snapshot from 'snap-shot'
it('is 42', () => {
  snapshot(42)
})

Run it first time with mocha spec.js. This will create snapshots JSON values file inside __snapshots__/spec.js.snap-shot. In general this file should close to Jest format, but the file extension is different to avoid clashing with Jest persistence logic.

$ mocha spec.js
$ cat __snapshots__/spec.js.snap-shot
module.exports[`is 42 1`] = 42

Now modify the spec.js file

const snapshot = require('snap-shot')
it('is 42', () => {
  snapshot(80)
})
$ mocha spec.js
1) is 42:
    Error: expected 42 got 80

Note snap-shot does not store or handle undefined values, since they are likely an edge case. If you disagree, open an issue please.

Note All values are saved as JSON, thus non-serializable values, like functions are stripped before comparison.

Promises

For asynchronous code, please have a function inside the spec before calling snap-shot or let snap-shot wrap the promise.

it('promise to function', () => {
  return Promise.resolve(20)
    .then(data => snapshot(data))
})

it('snap-shot can wrap promise', () => {
  return snapshot(Promise.resolve('value'))
})

// does NOT work
it('promise to snapshot', () => {
  return Promise.resolve(20)
    .then(snapshot)
})

In the last test, the stack trace from snap-shot cannot get any parent information, thus it cannot find the unit test.

See src/async-spec.js

Jest

You can use this assertion inside Jest tests too.

const snapshot = require('snap-shot')
test('my test', () => {
  snapshot(myValue)
})

Ava

Should work (including async / await syntax), see snap-shot-ava-test for the current status.

import test from 'ava'
import snapshot from 'snap-shot'
test('concat strings', t => {
  snapshot('f' + 'oo')
})

DOM testing (via jsdom and jsdom-global)

You can easily mock DOM and use snapshots (either in text or JSON format), see snap-shot-jsdom-test project.

React + JSX

If snap-shot finds .babelrc inside the current working folder, it will try transpiling loaded files using babel-core API. This makes it useful for testing React code. For full example see Link.test.js

Showing snapshots when saving

If you just want to see what a new schema would be, without saving it, run the tests with DRY=1 npm test option.

If you want to see the schema and save it, run the tests with SHOW=1 npm test

$ SHOW=1 npm test
saving snapshot "spec name" for file ./src/valid-message-spec.js
{ firstLine: 'break(log): new log format',
  type: 'major',
  scope: 'log',
  subject: 'new log format'
}

Update snapshots

To update all saved values, run with UPDATE=1 environment variable.

$ UPDATE=1 mocha spec.js

To update snapshot inside a single test function, use second argument

const snapshot = require('snap-shot')
it('is 42', () => {
  snapshot(80, true)
})
// snapshot file now has {"is 42": 80)

You can also update a single or several tests when running Mocha by filtering the tests using grep feature.

$ UPDATE=1 mocha -g "test name pattern" *-spec.js

CI

Note most CIs (like Travis, Circle, GitLabCI) define environment variable CI, which we take into consideration as well. It makes no sense to allow saving snapshot on CI, thus if the process.env.CI is set, the snapshot MUST exist on disk.

Format

There is no magic in formatting snapshots. Just use any function or compose with snapshot before comparing. Both choices work

const snapshot = require('snap-shot')
it('compares just keys', () => {
  const o = {
    foo: Math.random(),
    bar: Math.random()
  }
  snapshot(Object.keys(o))
})
// snapshot will be something like
/*
exports['compares just keys 1'] = [
  "foo",
  "bar"
]
*/

const compose = (f, g) => x => f(g(x))
const upperCase = x => x.toUpperCase()
const upValue = compose(snapshot, upperCase)

it('compares upper case string', () => {
  upValue('foo')
})
/*
exports['compares upper case string 1'] = "FOO"
*/

See src/format-spec.js

General advice

Simple is better. Format the data and then call snapshot.

it('works', () => {
  const domNode = ...
  const structure = formatHtml(domNode)
  snapshot(structure)
})

Tests with dynamic names

Sometimes tests are generated dynamically without hardcoded names. In this case SHA256 of the test callback function is used to find its value.

// this still works
const testName = 'variable test name (value 30)'
const value = 30
it(testName, () => {
  // this is a test without hard coded name
  snapshot(value)
})
// snapshot file will have something like
// exports['465fb... 1'] = 30

The best strategy in this case is to use meaningful name for the callback function

const testName = 'variable test name (value 30)'
const value = 30
it(testName, function is30() {
  snapshot(value)
})
// snapshot file will have something like
// exports['is30 1'] = 30

See src/unknown-name-spec.js

Multiple snapshots

A single test can have multiple snapshots.

it('handles multiple snapshots', () => {
  snapshot(1)
  snapshot(2)
})
it('uses counter of snapshot calls', () => {
  for (let k = 0; k < 10; k += 1) {
    snapshot(`snap ${k}`)
  }
})

See src/multiple-spec.js

Data-driven testing

Writing multiple input / output pairs for a function under test quickly becomes tedious. Luckily, you can test a function by providing multiple inputs and a single snapshot of function's behavior will be saved.

// checks if n is prime
const isPrime = n => ...
it('tests prime', () => {
  snapshot(isPrime, 1, 2, 3, 4, 5, 6, 7, 8, 9)
})

The saved snapshot file will have clear mapping between given input and produced result

// snapshot file
exports['tests prime 1'] = {
  "name": "isPrime",
  "behavior": [
    {
      "given": 1,
      "expect": false
    },
    {
      "given": 2,
      "expect": true
    },
    {
      "given": 3,
      "expect": true
    },
    {
      "given": 4,
      "expect": false
    },
    {
      "given": 5,
      "expect": true
    },
    ...
  ]
}

You can also test functions that expect multiple arguments by providing arrays of inputs.

const add = (a, b) => a + b
it('checks behavior of binary function add', () => {
  snapshot(add, [1, 2], [2, 2], [-5, 5], [10, 11])
})

Again, the snapshot file gives clear picture of the add behavior

// snapshot file
exports['checks behavior of binary function add 1'] = {
  "name": "add",
  "behavior": [
    {
      "given": [
        1,
        2
      ],
      "expect": 3
    },
    {
      "given": [
        2,
        2
      ],
      "expect": 4
    },
    {
      "given": [
        -5,
        5
      ],
      "expect": 0
    },
    {
      "given": [
        10,
        11
      ],
      "expect": 21
    }
  ]
}

See src/data-driven-spec.js for more examples.

Debugging

Run with DEBUG=snap-shot environment variable

$ DEBUG=snap-shot mocha spec.js

If you want to see messages only when new values are stored use

$ DEBUG=save mocha spec.js
save Saved for "is 42 1" snapshot 42

There are special projects that are setup to test this code in isolation as dependent projects, see above.

Related

Small print

Author: Gleb Bahmutov <[email protected]> ยฉ 2017

License: MIT - do anything with the code, but don't blame me if it does not work.

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2017 Gleb Bahmutov <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

snap-shot's People

Contributors

bahmutov avatar greenkeeper[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

snap-shot's Issues

Can it handle test names with template literals?

See if it can find the right test like this

const secondTest = 'second'
it(`handles template literals ${secondTest}`, () => {
  // this test has template literal instead of
  // primitive string
  snapshot(30)
})

Currently seems to not find the name and instead uses hash of the function callback

Unexpected snapshot id when using with Sazerac

I used snapshot within a sazerac assertion like this:

import todos from './todos'
import snapshot from 'snap-shot'
import { test, given } from 'sazerac'

test(todos, () => {

  given([], {
    type: 'ADD_TODO',
    text: 'Run the tests',
    id: 0
  })
  .assert('should return the snapshotted value', (newState) => {
    snapshot(newState)
  })

})

and the resulting snap-shot file after first test run ends up looking like:

// describer.js.snap-shot
exports['4b900bc2e67514543c299092313fe2b17fdd51c9f059973b12b7e56d702c32a1 1'] = [
  {
    "id": 0,
    "text": "Run the tests",
    "completed": false
  }
]

not sure where it's getting describer and the random hash from, might actually be a sazerac issue.

sort of related to #38

Single promise stack trace is missing

See src/async-spec.js test "promise to snapshot"

// async-spec.js
const snapshot = require('.')
it.only('promise to snapshot (does nothing!)', () => {
    // straight into snapshot comparison does not work
    return Promise.resolve(20)
      .then(snapshot)
})

The reported stack does not have "async-spec.js" at all, instead only has

  snap-shot [ { functionName: 'stackSites',
  snap-shot     filename: '/Users/irinakous/git/snap-shot/node_modules/stack-sites/src/index.js',
  snap-shot     line: 14,
  snap-shot     column: 13 },
  snap-shot   { functionName: 'snapshot',
  snap-shot     filename: '/Users/irinakous/git/snap-shot/src/index.js',
  snap-shot     line: 38,
  snap-shot     column: 17 } ] +0ms

Use full JSON stringify when printing results in DRY mode

Otherwise can shorten some values (in this case arrays of two numbers)

saving snapshot "checks behavior of binary function add 1" for 
file src/data-driven-spec.js
{ name: 'add',
  behavior: 
   [ { given: [Object], expect: 3 },
     { given: [Object], expect: 4 },
     { given: [Object], expect: 0 },
     { given: [Object], expect: 21 } ] }
    โœ“ checks behavior of binary function add

Support data-driven testing ala sazerac

See https://github.com/bahmutov/snap-shot-jest-test#data-driven-testing and https://hackernoon.com/sazerac-data-driven-testing-for-javascript-e3408ac29d8c#.3qht1jpdi and https://github.com/mikec/sazerac

import snapshot from 'snap-shot'
function snap(fn, inputs) {
  const output = inputs.map(fn)
  snapshot(output)
}

it('works for primes', () => {
  snap(isPrime, [2, 3, 5, 7])
})

it('works for non-primes', () => {
  snap(isPrime, [4, 6, 8, 10])
})

Good rule is two find two arguments, first being a function and a list of inputs second.

How to handle tests with dynamic names?

For example test like this one

const testName = 'variable test name (value 30)'
it(testName, () => {
  snapshot(30)
})

Maybe use serialized test function instead of the name?

JSX in source file crashes `find-test-caller`

I have tried following the steps outlined in various guides here, the main difference being that I am using Mocha and JSDOM instead of Jest. When running my tests I get the error Problem finding caller, which I debugged and traced to the function findTestCaller in the find-test-caller module.

After enabling debug output I got

  find-test-caller problem finding without transpiling /home/developer/dev/myproj/tests/mocha/client/unit/components/UserAccountInfo.test.js 87 +0ms
  find-test-caller Unexpected token (79:6) +1ms
  find-test-caller should transpile and search +1ms

Basically it advises me to transpile before searching, but I haven't seen any hints on doing this in the howtos I have seen. Any pointers? Of course, to run that test at all I already have transpiled the test inside Mocha (using babel-register).

This is the test code

  it('should render without regressions', function () {
    const renderer = ReactRenderer.create(
      <MuiThemeProvider muiTheme={muiTheme}>
        <UserAccountInfo {...createDefaultProps()}/>
      </MuiThemeProvider>
    );
    const json = renderer.toJSON();
    snapshot(json);
  });

Better string diff

When showing diff of multi-line strings show them with lines
Instead of foo\n 1 => foo\n 2 show separate lines

foo
 1
=>
foo
  2

or better show context just around the changed lines. This is mainly a change in visual-diff module

Only count calls to snapshot not text

For example it thinks there are two snapshots in the following code because it finds text "snapshot" twice

it('works', () => {
  // snapshot comparison
  snapshot(42)
})

Use callback function name if possible

If the name could not be determined, but callback function has a name, use the callback's name

const name = 'foo'
it(name, function testFoo() {
  snapshot('foo')
})

Use `jest-snapshot`?

Hey! I love what you are doing here. Did you know that the jest-snapshot package is standalone and can be used to use snapshots outside of Jest? I'd like to understand what motivated you to build a completely separate version of this feature rather than integrating jest-snapshot and sharing the same infrastructure across test frameworks. Thanks!

Follow same format as Jest

Snapshots for test file like sum.test.js should be saved into __snapshots__/sum.test.js.snap
with format

exports[`test adds 1 + 2 to equal 3 1`] = `3`;

exports[`test concat strings 1`] = `"foo"`;

Setup test project against Ava

Especially interesting async/await compatibility.

test('foo', async t => {
  const someObject = {...}
  t.snapshot(someObject) // built-in
  snapshot(someObject)
})

How to make work with JSX

If the test code has JSX, does not work, for example see https://github.com/bahmutov/snap-shot-jest-test/blob/master/Link.test.js - crashes on line <Link page="http://www.facebook.com">Facebook</Link>

import React from 'react';
import Link from './Link';
import renderer from 'react-test-renderer';
import snapshot from 'snap-shot'
test.skip('Link changes the class when hovered', () => {
  // snapshot does not know how to handle JSX
  const component = renderer.create(
    <Link page="http://www.facebook.com">Facebook</Link>
  );
  let tree = component.toJSON();
  snapshot(tree)
});

Does not have right stack in promises

There is a difference between callsites, stack exception and console.trace

// stack-site
[ { functionName: 'stackSites',
    filename: '/node_modules/stack-sites/src/index.js',
    line: 45,
    column: 13 },
  { functionName: 'snapshot',
    filename: '/node_modules/snap-shot/src/index.js',
    line: 157,
    column: 17 } ]
// console.trace
Trace
    at snapshot (/node_modules/snap-shot/src/index.js:166:13)
    at /test/fundamentals-api-spec.js:24:9
    at process._tickCallback (internal/process/next_tick.js:103:7)
// callsites
/node_modules/snap-shot/src/index.js 168 19
/test/fundamentals-api-spec.js 24 9
internal/process/next_tick.js 103 7

SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (4:0)

Trying to use this library with mocha (porting from chai-jest-snapshot because I don't really use chai anywhere else and don't want to depend on two assertion libraries):

the unit test:

import React from 'react';
import { describe, it } from 'mocha';
import toJson from 'enzyme-to-json';
import { shallow } from 'enzyme';
import matchSnapshot from 'snap-shot';

import { AboutAppScreen } from '../../src/components/Settings/AboutAppScreen';

describe('snapshot tests', function () {
  it('AboutAppScreen', function () {
    matchSnapshot(toJson(shallow(<AboutAppScreen />)));
  });
});

... when trying to run this, I get the following output:

 snapshot tests
    1) AboutAppScreen

  0 passing (324ms)
  1 failing

  1) snapshot tests AboutAppScreen:
     SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (4:0)
      at Parser.pp$4.raise (node_modules/acorn/dist/acorn.js:2221:15)
      at Parser.pp$1.parseStatement (node_modules/acorn/dist/acorn.js:717:16)
      at Parser.pp$1.parseTopLevel (node_modules/acorn/dist/acorn.js:638:25)
      at Parser.parse (node_modules/acorn/dist/acorn.js:516:17)
      at parse (node_modules/acorn/dist/acorn.js:3098:39)
      at module.exports (node_modules/falafel/index.js:22:15)
      at getSpecFunction (node_modules/snap-shot/src/index.js:48:3)
      at snapshot (node_modules/snap-shot/src/index.js:177:5)
      at Context.<anonymous> (test/snapshot/index.test.js:26:5)

Here's how my test currently looks like (using chai-jest-snapshot) where I pass the name of the test / snapshot explicitly:

-function assertMatchSnapshot (test, component) {
-  const tree = toJson(shallow(component));
-  const snapshotFileName = path.join(__dirname, `${test.title}.spec.js.snap`);
-  expect(tree).to.matchSnapshot(snapshotFileName, test.fullTitle());
-}
-
 describe('snapshot tests', function () {
   it('AboutAppScreen', function () {
-    assertMatchSnapshot(this.test, <AboutAppScreen />);
+    matchSnapshot(toJson(shallow(<AboutAppScreen />)));
   });

Can I pass the name of the snapshot explicitly and opt out of the smart AST parsing ?

The above example is using v1.11.0 of snap-shot.

composed snapshot

Does not find the right source location if the snapshot was used in composition, for example src/format-spec.js

const compose = (f, g) => x => f(g(x))
const upperCase = x => x.toUpperCase()
const upValue = compose(snapshot, upperCase)
it('compares upper case string', () => {
  upValue('foo')
})

Should find upValue call

Add utility to handle multiple names where the name cannot be determined

In these tests the hash of the test will be the same and we will think they are the same

const names = ['foo', 'bar']
names.forEach(name => {
  it(name, () => {
    snapshot(name)
  })
})

it might be simple if it thinks it is same test, just different snapshots equivalent to

const names = ['foo', 'bar']
it(function () => {
  snapshot('foo')
  snapshot('bar')
})

multiple snapshots work in #1

Require a snapshot for use in other tests.

I have this usecase where I would like to store my snapshot(happens automatically). The next time I run the test I would like it to use that snapshot (which is an array of things) to loop over. The reason is because I know the snapshot is valid. If the data that the snapshot was taken from changes, my other tests do keep running because they use the verified snapshot data.

  • Should I be doing it this way?
  • Would/should it be possible with snap-shot?

Unable to determine caller function callsite

Trying a really simple test with snap-shot and it seems to always be unable to determine the calling function.

Using [email protected], [email protected], and [email protected] on windows.

Test File

"use strict";

var snapshot = require("snap-shot");

it("should test using snapshots", () => {
    snapshot(42);
});

Output

> [email protected] test
> mocha

  1) should test using snapshots

  0 passing (8ms)
  1 failing

  1)  should test using snapshots:
     Error: Do not have caller function callsite
      at snapshot (node_modules\snap-shot\src\index.js:63:11)
      at Context.it (test\snap-shot.test.js:6:5)

Am I doing something wrong here?

support multiple snapshots per test

for example this should keep track of 3 snapshots for single test function "works"

it('works', () => {
  snapshot(10)
  snapshot(20)
  snapshot(30)
})

Make it work in the browser with karma

I don't know if its something for this repo, but I am using real browsers, because tests are partially dom related and need to be tested in all the browsers. It would be cool to be able to use snapshots there as well. I realize its an entirely different thing, but maybe we can work something out.

Doesn't support test names with apostrophes

it("should support apostrophe'd test names", () => {
    snapshot(42);
});

will succeed on the first run, but create a snapshot file like this.

exports['should support apostrophe'd test names 1'] = 42

(note the single-quote within single-quotes that makes the snapshot invalid javascript).

Then any later attempts to run the tests cause a massive ๐Ÿ”ฅ

exports['should support apostrophe'd test names 1'] = 42


evalmachine.<anonymous>:1
exports['should support apostrophe'd test names 1'] = 42
                                   ^
SyntaxError: Unexpected identifier
    at createScript (vm.js:53:10)
    at Object.runInNewContext (vm.js:91:10)
    at loadSnaps (C:\Users\pcavit\Desktop\snap-shot\node_modules\snap-shot-core\src\file-system.js:26:8)
    at Object.loadSnapshots (C:\Users\pcavit\Desktop\snap-shot\node_modules\snap-shot-core\src\file-system.js:5
4:17)
    at storeValue (C:\Users\pcavit\Desktop\snap-shot\node_modules\snap-shot-core\src\index.js:59:24)
    at setOrCheckValue (C:\Users\pcavit\Desktop\snap-shot\node_modules\snap-shot-core\src\index.js:114:7)
    at snapShotCore (C:\Users\pcavit\Desktop\snap-shot\node_modules\snap-shot-core\src\index.js:138:12)
    at setOrCheckValue (C:\Users\pcavit\Desktop\snap-shot\node_modules\snap-shot\src\index.js:137:5)
    at snapshot (C:\Users\pcavit\Desktop\snap-shot\node_modules\snap-shot\src\index.js:151:12)
    at Context.it (C:\Users\pcavit\Desktop\snap-shot\test\snap-shot.test.js:6:5)
    at callFn (C:\Users\pcavit\Desktop\snap-shot\node_modules\mocha\lib\runnable.js:345:21)
    at Test.Runnable.run (C:\Users\pcavit\Desktop\snap-shot\node_modules\mocha\lib\runnable.js:337:7)
    at Runner.runTest (C:\Users\pcavit\Desktop\snap-shot\node_modules\mocha\lib\runner.js:444:10)
    at C:\Users\pcavit\Desktop\snap-shot\node_modules\mocha\lib\runner.js:550:12
    at next (C:\Users\pcavit\Desktop\snap-shot\node_modules\mocha\lib\runner.js:361:14)
    at C:\Users\pcavit\Desktop\snap-shot\node_modules\mocha\lib\runner.js:371:7
    at next (C:\Users\pcavit\Desktop\snap-shot\node_modules\mocha\lib\runner.js:295:14)
    at Immediate.<anonymous> (C:\Users\pcavit\Desktop\snap-shot\node_modules\mocha\lib\runner.js:339:5)
    at runCallback (timers.js:666:20)
    at tryOnImmediate (timers.js:639:5)
    at processImmediate [as _immediateCallback] (timers.js:611:5)
  โˆš should support apostrophe'd test names

  1 passing (22ms)

which for some reason is still considered a passing test?

Allow passing comparator function

Like https://github.com/staltz/html-looks-like to compare expected (snapshot) and actual value.
Maybe check if the function is binary to tell apart from data-driven testing

const isPrime = n => ...
snapshot(isPrime, 1, 2, 3)
// data-drive, because isPrime is unary?
const htmlLooksLike = require('html-looks-like')
snapshot(htmlLooksLike, someText)
// comparator function because binary function and single value

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.