-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun.js
29 lines (25 loc) · 826 Bytes
/
run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const glob = require('glob')
const path = require('path')
const tape = require('tape')
const common = require('./common')
const suite = process.argv[2] || ['unit']
// find all files ending in .test.js
const files = glob.sync('**/*.test.js', { realpath: true })
// unit and functional test predecates
const unit = (f) => !/\/test\//.test(f)
// const func = (f) => /\/test\//.test(f)
// test runner
const run = (f) => {
const exp = require(f)
for (const prop in exp) {
const test = exp[prop]
test((label, func) => {
const filename = path.basename(f, '.test.js')
let display = `${prop}`
if (label !== prop) { display = `${prop}: ${label}` }
return tape(`${filename}: ${display}`, func)
}, common)
}
}
// run unit tests
if (suite.includes('unit')) { files.filter(unit).forEach(run) }