From 25ea35622a321a9fd0c4992b4e17ec47c01d3b15 Mon Sep 17 00:00:00 2001 From: jhen Date: Thu, 27 Jul 2023 17:32:56 +0800 Subject: [PATCH] E2E: Take screenshot after each & upload artifacts on CI failed --- .github/workflows/main.yml | 24 ++++++++++++++++++++++++ .gitignore | 1 + __e2e__/app.spec.js | 5 +++++ 3 files changed, 30 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ca535834..516e1fdc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,12 +18,20 @@ jobs: - name: Setup run: sudo apt-get install -y libgbm-dev - name: Test + id: test run: | yarn cd npm-package && yarn && cd .. yarn test yarn build xvfb-run --auto-servernum yarn test-e2e + - name: Upload artifacts on failure + if: ${{ failure() && steps.test.conclusion == 'failure' }} + uses: actions/upload-artifact@v3 + with: + name: artifacts + path: artifacts + retention-days: 1 build-test-macos: runs-on: macOS-latest steps: @@ -33,12 +41,20 @@ jobs: node-version: 18.x cache: 'yarn' - name: Test + id: test run: | yarn cd npm-package && yarn && cd .. yarn test yarn build yarn test-e2e + - name: Upload artifacts on failure + if: ${{ failure() && steps.test.conclusion == 'failure' }} + uses: actions/upload-artifact@v3 + with: + name: artifacts + path: artifacts + retention-days: 1 build-test-windows: runs-on: windows-2022 steps: @@ -48,6 +64,7 @@ jobs: node-version: 18.x cache: 'yarn' - name: Test + id: test shell: bash run: | yarn config set network-timeout 500000 -g @@ -56,3 +73,10 @@ jobs: yarn build yarn test yarn test-e2e + - name: Upload artifacts on failure + if: ${{ failure() && steps.test.conclusion == 'failure' }} + uses: actions/upload-artifact@v3 + with: + name: artifacts + path: artifacts + retention-days: 1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 32625db5..ad21da65 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ release/ tmp/ config_test .idea/ +artifacts/ diff --git a/__e2e__/app.spec.js b/__e2e__/app.spec.js index bb185976..1e97b913 100644 --- a/__e2e__/app.spec.js +++ b/__e2e__/app.spec.js @@ -33,6 +33,11 @@ describe('Application launch', () => { await mainWindow.waitForLoadState() }) + afterEach(async () => { + const state = expect.getState() + await mainWindow.screenshot({ path: `./artifacts/${state.currentTestName}.png` }) + }) + afterAll(async () => { await electronApp.close() })