npm/with-fixtures

Name: with-fixtures

Owner: npm

Description: null

Created: 2016-10-19 03:55:40.0

Updated: 2016-10-19 06:21:52.0

Pushed: 2017-01-02 21:13:04.0

Homepage: null

Size: 5

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

withFixtures

A test helper to make sure fixtures are torn down and error messages are retained

Summary
tion withFixtures([Fixture, Fixture, ...], Fn -> Promise<Any>) -> Promise<Any>
Example
t withFixtures = require('with-fixtures');

Fixtures([
xture1,
xture2
) => {
 Do test here and return a promise
hen(() => console.log("Test passed"), err => cosole.warn("test failed"));
Notes

A Fixture is an object with a done() method. Any errors thrown while tearing down the fixture in the done method will be captured, and the first will be reported as a rejection of the promise chain, if the test itself did not reject.

All of the fixtures will have their done() method called.

For compatibility with sinon, if there is no done() method on a fixture but there is a restore() method, that will be called instead.

The promise will resolve to one of the following:

  1. The rejection of the lifted function, if it exists
  2. The first rejection while tearing down a fixture, if any
  3. The value returned by the lifted function.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.