Add failure notifications via slack
Change-Id: If9f5711497c838a8f307fbc078b59672353ed5d3
diff --git a/test/korap-ui.js b/test/korap-ui.js
index 9adfbc8..42cd5dd 100644
--- a/test/korap-ui.js
+++ b/test/korap-ui.js
@@ -4,6 +4,7 @@
const { doesNotMatch } = require('assert');
const assert = chai.assert;
const should = chai.should();
+var slack = null;
const KORAP_URL = process.env.KORAP_URL || "http://localhost:64543";
const KORAP_LOGIN = 'KORAP_LOGIN' in process.env ? process.env.KORAP_LOGIN : "user2"
@@ -11,6 +12,11 @@
const KORAP_QUERIES = process.env.KORAP_QUERIES || 'geht, [orth=geht & cmc/pos=VVFIN]'
const korap_rc = require('../lib/korap_rc.js').new(KORAP_URL)
+const slack_webhook = process.env.SLACK_WEBHOOK_URL;
+if (slack_webhook) {
+ slack = require('slack-notify')(slack_webhook);
+}
+
function ifConditionIt(title, condition, test) {
return condition ? it(title, test) : it.skip(title + " (skipped)", test)
}
@@ -36,6 +42,11 @@
afterEach(async function () {
if (this.currentTest.state == "failed") {
await page.screenshot({path: "failed_" + this.currentTest.title.replaceAll(/[ &\/]/g, "_") + '.png'});
+ if (slack) {
+ slack.alert({
+ text: 'Test on ' + KORAP_URL + ' failed: ' + this.currentTest.title,
+ })
+ }
}
})