From c46a5ddc4a2f72632b3ead8ef121784669a3b2db Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Wed, 7 Dec 2022 17:50:43 +0530 Subject: [PATCH 1/2] Added GH Actions summary --- .github/workflows/cypress.yml | 18 ++++++++++++++++++ .gitignore | 5 +++++ package.json | 3 ++- tests/cypress/config.json | 8 ++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index f7d4c34c..c6e15c05 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -31,3 +31,21 @@ jobs: run: npm run env:start - name: Test run: npm run cypress:run + - name: Update summary + run: | + npx mochawesome-merge ./tests/cypress/reports/*.json -o tests/cypress/reports/mochawesome.json + rm -rf ./tests/cypress/reports/mochawesome-*.json + npx mochawesome-json-to-md -p ./tests/cypress/reports/mochawesome.json -o ./tests/cypress/reports/mochawesome.md + npx mochawesome-report-generator tests/cypress/reports/mochawesome.json -o tests/cypress/reports/ + cat ./tests/cypress/reports/mochawesome.md >> $GITHUB_STEP_SUMMARY + - name: Make artifacts available + uses: actions/upload-artifact@v2 + if: failure() + with: + name: cypress-artifact + retention-days: 2 + path: | + ${{ github.workspace }}/tests/cypress/screenshots/ + ${{ github.workspace }}/tests/cypress/videos/ + ${{ github.workspace }}/tests/cypress/logs/ + ${{ github.workspace }}/tests/cypress/reports/ diff --git a/.gitignore b/.gitignore index 81949283..dcc363e6 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,8 @@ Session.vim # Windows Thumbs.db Desktop.ini + +# Cypress +tests/cypress/screenshots +tests/cypress/videos +tests/cypress/reports diff --git a/package.json b/package.json index 7be6fe3e..810005ef 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@wordpress/env": "^5.2.0", "@wordpress/scripts": "^23.0.0", "cypress": "^9.5.4", - "cypress-file-upload": "^5.0.8" + "cypress-file-upload": "^5.0.8", + "cypress-mochawesome-reporter": "^3.0.1" } } diff --git a/tests/cypress/config.json b/tests/cypress/config.json index 3c05e2ec..9dd5143e 100644 --- a/tests/cypress/config.json +++ b/tests/cypress/config.json @@ -7,6 +7,14 @@ "downloadsFolder": "tests/cypress/downloads", "supportFile": "tests/cypress/support/index.js", "video": false, + "reporter": "mochawesome", + "reporterOptions": { + "reportFilename": "mochawesome-[name]", + "reportDir": "tests/cypress/reports", + "overwrite": false, + "html": false, + "json": true + }, "testFiles": [ "set-avatar.test.js", "choose-default-avatar.test.js", From a234e62d512d2002c27ba6401f738c866399c488 Mon Sep 17 00:00:00 2001 From: Faisal Alvi Date: Mon, 12 Dec 2022 11:45:45 +0530 Subject: [PATCH 2/2] Update .github/workflows/cypress.yml Co-authored-by: Dharmesh Patel --- .github/workflows/cypress.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index c6e15c05..b7949824 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -32,6 +32,7 @@ jobs: - name: Test run: npm run cypress:run - name: Update summary + if: ${{ always() }} run: | npx mochawesome-merge ./tests/cypress/reports/*.json -o tests/cypress/reports/mochawesome.json rm -rf ./tests/cypress/reports/mochawesome-*.json