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