UNPKG

517 BJavaScriptView Raw
1const Mocha = require('mocha')
2const fs = require('fs')
3const path = require('path')
4
5// Instantiate a Mocha instance.
6var mocha = new Mocha()
7
8var testDir = 'test'
9
10// Add each .js file to the mocha instance
11fs.readdirSync(testDir).filter(function (file) {
12 // Only keep the .js files
13 return file.substr(-3) === '.js'
14}).forEach(function (file) {
15 mocha.addFile(path.join(testDir, file))
16})
17
18// Run the tests.
19mocha.run(function (failures) {
20 process.on('exit', function () {
21 process.exit(failures)
22 })
23})