.ci/templates/steps/test.yml
parameters:
codeCoverage: 'false'
steps:
- ${{ if eq(parameters.codeCoverage, 'true') }}:
- script: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build -d
displayName: 'Hook Code Climate Coverage Status'
condition: ne(variables['GIT_BRANCH'], 'merge')
- script: |
npm run test:coverage
env:
GH_NPM_REGISTRY_TOKEN: ''
displayName: 'Run Tests and Generate Coverage Report'
- script: |
./cc-test-reporter format-coverage -d -t lcov ./coverage/lcov.info
./cc-test-reporter upload-coverage -d
displayName: 'Publish LCOV result to Code Climate'
condition: ne(variables['GIT_BRANCH'], 'merge')
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/*.test.xml'
failTaskOnFailedTests: true
displayName: 'Publish Test Results'
condition: always()
- ${{ if eq(parameters.codeCoverage, 'false') }}:
- script: |
npm run test:headless
displayName: 'Run Tests'