From 986630d0a1a481cfff3d4f0733432bf40b000137 Mon Sep 17 00:00:00 2001 From: Ajay Date: Sat, 18 Jun 2022 11:54:52 -0400 Subject: [PATCH] Save file on test failure Fixes #1366 --- .github/workflows/tests.yml | 9 ++++++++- .gitignore | 3 ++- test/selenium.test.ts | 10 ++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5a87e1ee..b14925ec 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,4 +19,11 @@ jobs: - name: Copy configuration run: cp config.json.example config.json - name: Run tests - run: npm run test \ No newline at end of file + run: npm run test + + - name: Upload results on fail + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: Test Results + path: ./test-results \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2eafbe10..f108301d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ web-ext-artifacts dist/ tmp/ .DS_Store -ci/data.json \ No newline at end of file +ci/data.json +test-results \ No newline at end of file diff --git a/test/selenium.test.ts b/test/selenium.test.ts index 6d522f03..600408a9 100644 --- a/test/selenium.test.ts +++ b/test/selenium.test.ts @@ -2,6 +2,8 @@ import { Builder, By, until, WebDriver, WebElement } from "selenium-webdriver"; import * as Chrome from "selenium-webdriver/chrome"; import * as Path from "path"; +import * as fs from "fs"; + test("Selenium Chrome test", async () => { let driver: WebDriver; try { @@ -35,6 +37,14 @@ test("Selenium Chrome test", async () => { await toggleWhitelist(driver); await toggleWhitelist(driver); + } catch (e) { + // Save file incase there is a layout change + const source = await driver.getPageSource(); + + fs.mkdirSync("./test-results"); + fs.writeFileSync("./test-results/source.html", source); + + throw e; } finally { await driver.quit(); }