Skip to content

Instantly share code, notes, and snippets.

Forked from ericelliott/fancy-without-features.js
Last active September 17, 2017 23:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save joyrexus/41571e24dcffd51f051db11deb0d73bb to your computer and use it in GitHub Desktop.
just use tape
import test from 'tape';
const before = test;
const after = test;
// beforeEach/afterEach rely on shared state.
// That's a big anti-pattern for testing.
// It's also silly to run something before and after
// ever test -- many of your tests won't need it.
// Try this, instead:
const setup = () => {
const fixtures = {};
// Insert your fixture code here.
// Make sure you're creating fresh objects each
// time setup() is called.
return fixtures;
const teardown = (fixtures) => {
// Dispose of your fixtures here.
before('before', function (assert) {
assert.pass('Do something before tests here');
test('A test with fixtures', (assert) => {
const fixture = setup();
assert.equal(typeof fixture, 'object',
'fixture should return an object');
test('A passing test', (assert) => {
assert.pass('This test will pass.');
test('Assertions with tape.', (assert) => {
const expected = 'something to test';
const actual = 'sonething to test';
assert.equal(actual, expected,
'Given two mismatched values, .equal() should produce a nice bug report');
after('after', (assert) => {
assert.pass('Do something after tests here.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment