From 3e52240583e663626ba5d68bd091b889eb1d6fa6 Mon Sep 17 00:00:00 2001 From: Niranjan N <110103643+niranjan-n1@users.noreply.github.com> Date: Tue, 4 Apr 2023 17:50:33 +0530 Subject: [PATCH] GitHub action for Unit test (#555) * added github action for unit test * updated unit-test-reporter.yaml * updated unit-test-reporter.yaml --- .github/workflows/unit-test-reporter.yaml | 24 +++++++++++++++++++ .gitignore | 1 + .../csminstallationwizard/src/jest.config.js | 7 +++++- .../csminstallationwizard/src/package.json | 5 ++-- 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/unit-test-reporter.yaml diff --git a/.github/workflows/unit-test-reporter.yaml b/.github/workflows/unit-test-reporter.yaml new file mode 100644 index 0000000000..c25bdbf9e9 --- /dev/null +++ b/.github/workflows/unit-test-reporter.yaml @@ -0,0 +1,24 @@ +name: Unit Test Action + +on: + push: + branches: [ main ] + pull_request: + branches: [ main, release-1.7.0 ] +jobs: + build-test: + name: Build & Run Unit Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Run Tests + working-directory: ./content/docs/deployment/csminstallationwizard/src/ + run: | + npm install + npm test + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + files: | + ./content/docs/deployment/csminstallationwizard/src/reports/*.xml \ No newline at end of file diff --git a/.gitignore b/.gitignore index 52500d00df..3de56ef5f7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ public/ resources/ .hugo_build.lock coverage/ +reports/ diff --git a/content/docs/deployment/csminstallationwizard/src/jest.config.js b/content/docs/deployment/csminstallationwizard/src/jest.config.js index 046cf487f3..7ea7845d6d 100644 --- a/content/docs/deployment/csminstallationwizard/src/jest.config.js +++ b/content/docs/deployment/csminstallationwizard/src/jest.config.js @@ -26,5 +26,10 @@ module.exports = { setupFiles: ["./jest.setup.js"], // The test environment that will be used for testing - testEnvironment: "jsdom" + testEnvironment: "jsdom", + + reporters: [ + 'default', + ['jest-junit', {outputDirectory: 'reports', outputName: 'report.xml'}], + ] }; diff --git a/content/docs/deployment/csminstallationwizard/src/package.json b/content/docs/deployment/csminstallationwizard/src/package.json index 69a836116e..51b347c5d5 100644 --- a/content/docs/deployment/csminstallationwizard/src/package.json +++ b/content/docs/deployment/csminstallationwizard/src/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "", "scripts": { - "test": "jest", + "test": "jest --ci", "coverage": "jest --coverage" }, "repository": { @@ -19,6 +19,7 @@ "devDependencies": { "jest": "^29.3.1", "jest-environment-jsdom": "^29.3.1", - "jquery": "^3.6.3" + "jquery": "^3.6.3", + "jest-junit": "^15.0.0" } }