Make screenshot on failed tests
Change-Id: I16f5c2314fce1576eb1eda26ddff7b156e530988
diff --git a/test/korap-ui.js b/test/korap-ui.js
index 79bd0b0..878b498 100644
--- a/test/korap-ui.js
+++ b/test/korap-ui.js
@@ -1,5 +1,7 @@
const puppeteer = require('puppeteer')
const chai = require('chai');
+const { afterEach } = require('mocha');
+const { doesNotMatch } = require('assert');
const assert = chai.assert;
const should = chai.should();
@@ -18,12 +20,24 @@
before(async () => {
browser = await puppeteer.launch()
page = await browser.newPage()
+ await page.setViewport({
+ width: 1280,
+ height: 768,
+ deviceScaleFactor: 1,
+ });
})
after(async () => {
await browser.close()
})
+ afterEach(async function () {
+ if (this.currentTest.state == "failed") {
+ console.log(this.currentTest);
+ await page.screenshot({path: "failed_" + this.currentTest.title.replaceAll(/[ ]/g, "_") + '.png'});
+ }
+ })
+
it('KorAP UI is up and running',
(async () => {
await await page.goto(KORAP_URL);