Last active
March 15, 2016 21:10
-
-
Save MylesBorins/f7b7ca8431f6902f2d10 to your computer and use it in GitHub Desktop.
Tap setup / teardown example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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