-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (31 loc) · 1012 Bytes
/
index.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
36
37
38
const notifier = require("node-notifier");
const { readRuntimeConfig } = require("./read_config");
const { runTests } = require("./run_tests");
let latestStatus = "";
const sendNotification = config => message => {
notifier.notify(message);
};
const handleEventChange = event => {
const eventMessage = Buffer.from(event.data).toString();
const passOrFail = eventMessage.match(/PASS|FAIL/);
if (!!passOrFail && passOrFail[0] !== latestStatus) {
latestStatus = passOrFail[0];
sendNotification()(passOrFail[0]);
}
};
module.exports = async () => {
try {
const runtimeConfig = await readRuntimeConfig();
runTests(runtimeConfig.run).on("event", event => {
process.stdout.write(event.data);
handleEventChange(event);
});
} catch (e) {
console.log(e.message, e);
}
};
// ok, make this somehow execute jest or mocha, or whatever the user wants
// output everything to the console
// invoke the node-notifier when any test breaks
// done
process.stdin.resume();