Skip to content

Instantly share code, notes, and snippets.

@MylesBorins
Last active March 15, 2016 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MylesBorins/f7b7ca8431f6902f2d10 to your computer and use it in GitHub Desktop.
Save MylesBorins/f7b7ca8431f6902f2d10 to your computer and use it in GitHub Desktop.
Tap setup / teardown example
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
var test = require('tap').test;
var path = require('path');
var os = require('os');
var fs = require('fs');
var mkdirp = require('mkdirp');
var rimraf = require('rimraf');
var tmpdir = path.join(os.tmpdir(), 'example', 'test-example');
test('test-example: setup', function (t) {
t.plan(2);
mkdirp(tmpdir, function (err) {
t.error(err);
var exists = fs.existsSync(tmpdir);
t.ok(exists, 'the temp directory should exist');
});
});
// Insert tests here!
test('test-example: teardown', function (t) {
t.plan(2);
rimraf(tmpdir, function (err) {
t.error(err);
var exists = fs.existsSync(tmpdir);
t.notok(exists, 'the temp directory should no longer exist');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment