Skip to content

Instantly share code, notes, and snippets.

@wmakeev
Last active July 22, 2016 12:34
Show Gist options
  • Save wmakeev/096ec10c3ee11989760950bff61963e6 to your computer and use it in GitHub Desktop.
Save wmakeev/096ec10c3ee11989760950bff61963e6 to your computer and use it in GitHub Desktop.
TAP tests environments
// Run all node-tap test in __test__ dirs from ./src root
// test/index.js
let tap = require('tap')
let reporter = require('tap-mocha-reporter')
let walk = require('walkdir')
let testFilePattern = /__tests__[\/\\]+.+-test\.js$/i
// from https://github.com/tapjs/node-tap/issues/168
tap.unpipe(process.stdout)
tap.pipe(reporter('spec'))
walk.sync('src', function (path, stat) {
if (testFilePattern.test(path)) {
let testModule = require(path)
Object.keys(testModule).forEach(testName => {
tap.test(testName, testModule[testName])
})
}
})
// src/**/__tests__/some-test.js
/* eslint no-shadow: 0 */
function Foo (t) {
t.ok(true, 'Foo is ok')
t.test('Sub Foo', t => {
t.ok(true, 'sub Foo is ok')
t.end()
})
t.end()
}
module.exports = { Foo }
'use strict'
let test = require('blue-tape')
let walk = require('walkdir')
let testFilePattern = /__tests__[\/\\]+.+-test\.js$/i
test.createStream()
// .pipe(reporter())
.pipe(process.stdout)
walk.sync('src', function (path, stat) {
if (testFilePattern.test(path)) {
let testModule = require(path)
Object.keys(testModule).forEach(testName => {
test(testName, testModule[testName])
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment