pactest/runTest.js
Sander Hautvast 9e8b0de006
Some checks failed
test / Test completion check (push) Has been cancelled
test / test (20, macos-latest) (push) Has been cancelled
test / test (20, ubuntu-latest) (push) Has been cancelled
test / test (20, windows-latest) (push) Has been cancelled
test / test (22, macos-latest) (push) Has been cancelled
test / test (22, ubuntu-latest) (push) Has been cancelled
test / test (22, windows-latest) (push) Has been cancelled
test / test (24, macos-latest) (push) Has been cancelled
test / test (24, ubuntu-latest) (push) Has been cancelled
test / test (24, windows-latest) (push) Has been cancelled
Initial commit
2025-09-03 11:48:59 +02:00

33 lines
898 B
JavaScript

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);
}
});
},
};