-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunTest.js
35 lines (31 loc) · 879 Bytes
/
runTest.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
30
31
32
33
34
35
const { pactFile } = require('./pact.js')
// Let's use async/await
module.exports = {
runTests: testTypes => {
const Mocha = require('mocha')
const fs = require('fs')
const path = require('path')
// Instantiate a Mocha instance.
const mocha = new Mocha()
// Add spec files
testTypes.forEach(testType => {
const testDir = `${__dirname}/${testType}`;
fs.readdirSync(testDir)
.filter(file => file.endsWith('spec.js'))
.forEach(file => mocha.addFile(path.join(testDir, file)))
})
mocha.timeout(15000)
mocha.run(failures => {
if (failures) {
console.log(
`test failed :(\nOpen the log file in ./logs to see what happened`
)
} else {
console.log(
`test passed! Open the pact file in ${pactFile}`
)
}
})
mocha.timeout(15000)
},
}