Giter VIP home page Giter VIP logo

assert-snapshot's Introduction

assert-snapshot stability

npm version build status downloads js-standard-style

Snapshot UI testing for tape tests. Inspired by Jest snapshot testing, but implemented as a module instead of a custom runtime.

Usage

var snap = require('assert-snapshot')
var tape = require('tape')
var html = require('bel')

tape('my cool component', function (assert) {
  var str = myComponent().toString()
  snap(assert, str)
  assert.end()
})

function myComponent () {
  return html`
    <section>
      Hello planet
    </section>
  `
}

Outputs

TAP version 13
# my cool component
ok 1 snapshot found for "my cool component"
ok 2 <section>
ok 3 ·· Hello planet
ok 4 </section>

1..4
# tests 4
# pass  4

# ok

Updating snapshots

By default no snapshot is saved. Set the UPDATE_SNAPSHOT=true env variable to update the snapshot and save it to snapshot.json. Each snapshot is saved using the name of the test as the key, so make sure test names are unique.

$ UPDATE_SNAPSHOT=true node example.js

API

snapshot(assert, html, [cache])

Assert a string of HTML using a custom assert function. Takes an optional cache object that contains the expected values. Use this if snapshot tests become I/O bound.

See Also

License

MIT

assert-snapshot's People

Contributors

yoshuawuyts 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

Watchers

 avatar  avatar  avatar

Forkers

emkay

assert-snapshot's Issues

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.