From d43d305092f169ecbd6cbd3b591a73b9406df8c4 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Thu, 22 Nov 2018 14:42:12 +0530 Subject: [PATCH] Test reports are not being published to Azure Pipelines (#5715) This PR is related to the issue #5713 The PR helps to publish test results for reporting in Azure Pipelines. Azure Pipelines provides excellent reporting capabilities that can be leveraged by this PR. An example report is shown in the image below. ![image](https://user-images.githubusercontent.com/13175100/48767951-e8a73580-ecdd-11e8-8e6a-20d7767d7c1b.png) --- azure-pipelines.yml | 12 ++++++++++++ jest.config.js | 3 ++- package.json | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6dab13bf..7f27eedd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -26,3 +26,15 @@ steps: - script: | yarn test displayName: 'Run tests' + +- task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFiles: '**junit*.xml' + testRunTitle: TestRun ${{ parameters.name }} $(node_version) + +- task: PublishCodeCoverageResults@1 + displayName: 'Publish code coverage results' + inputs: + codeCoverageTool: 'cobertura' + summaryFileLocation: '**/coverage/cobertura-coverage.xml' \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index 1a481c6b..2433cbf7 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,5 +8,6 @@ module.exports = { rootDir: 'test', modulePaths: ['/lib'], globalSetup: '/jest-global-setup.js', - globalTeardown: '/jest-global-teardown.js' + globalTeardown: '/jest-global-teardown.js', + coverageReporters: ['text', 'lcov', 'cobertura'] } diff --git a/package.json b/package.json index eef2c097..eaf257b5 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "bootstrap": "lerna bootstrap", "dev": "lerna run build --stream --parallel", "testonly": "jest", - "testall": "npm run testonly -- --coverage --forceExit --runInBand", + "testall": "npm run testonly -- --coverage --forceExit --runInBand --reporters=default --reporters=jest-junit", "pretest": "npm run lint", "test": "npm run testall || npm run testall", "coveralls": "cat ./test/coverage/lcov.info | coveralls", @@ -52,6 +52,7 @@ "fkill": "5.1.0", "flatten": "1.0.2", "get-port": "3.2.0", + "jest-junit": "^5.0.0", "jest-cli": "23.6.0", "lerna": "^3.4.0", "lint-staged": "4.2.3",