jest-coverage-report-action
jest-coverage-report-action copied to clipboard
TypeError: Reduce of empty array with no initial value
Describe a bug
2022-01-29T17:26:42.2204524Z ##[group]Run ArtiomTr/[email protected]
2022-01-29T17:26:42.2204826Z with:
2022-01-29T17:26:42.2205233Z github-token: ***
2022-01-29T17:26:42.2205464Z skip-step: all
2022-01-29T17:26:42.2205691Z annotations: none
2022-01-29T17:26:42.2205948Z coverage-file: ./coverage/report.json
2022-01-29T17:26:42.2206245Z base-coverage-file: ./coverage/main.json
2022-01-29T17:26:42.2206519Z test-script: npx jest
2022-01-29T17:26:42.2206749Z icons: emoji
2022-01-29T17:26:42.2206980Z package-manager: npm
2022-01-29T17:26:42.2208742Z ##[endgroup]
2022-01-29T17:26:42.2227619Z ##[group]Run $GITHUB_ACTION_PATH/run.sh
2022-01-29T17:26:42.2228036Z [36;1m$GITHUB_ACTION_PATH/run.sh[0m
2022-01-29T17:26:42.2283455Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2022-01-29T17:26:42.2283741Z env:
2022-01-29T17:26:42.2285483Z INPUT_GITHUB-TOKEN: ***
2022-01-29T17:26:42.2285741Z INPUT_TEST-SCRIPT: npx jest
2022-01-29T17:26:42.2285986Z INPUT_THRESHOLD:
2022-01-29T17:26:42.2286245Z INPUT_WORKING-DIRECTORY:
2022-01-29T17:26:42.2286494Z INPUT_ICONS: emoji
2022-01-29T17:26:42.2286736Z INPUT_ANNOTATIONS: none
2022-01-29T17:26:42.2287001Z INPUT_PACKAGE-MANAGER: npm
2022-01-29T17:26:42.2287255Z INPUT_SKIP-STEP: all
2022-01-29T17:26:42.2287493Z INPUT_CUSTOM-TITLE:
2022-01-29T17:26:42.2287765Z INPUT_COVERAGE-FILE: ./coverage/report.json
2022-01-29T17:26:42.2288087Z INPUT_BASE-COVERAGE-FILE: ./coverage/main.json
2022-01-29T17:26:42.2288353Z ##[endgroup]
2022-01-29T17:26:42.2431369Z Running using node v14.18.3
2022-01-29T17:26:42.3659845Z Begin initialization stage...
2022-01-29T17:26:42.3686139Z Initialization stage ended
2022-01-29T17:26:42.3686829Z Begin stages.parsethreshold...
2022-01-29T17:26:42.6722142Z stages.parseThreshold ended
2022-01-29T17:26:42.6727690Z Begin head coverage collection...
2022-01-29T17:26:42.6732349Z Begin installing dependencies...
2022-01-29T17:26:42.6732892Z Installing dependencies skipped
2022-01-29T17:26:42.6733828Z Installing dependencies ended
2022-01-29T17:26:42.6734296Z Begin running tests...
2022-01-29T17:26:42.6734923Z Running tests skipped
2022-01-29T17:26:42.6735334Z Running tests ended
2022-01-29T17:26:42.6735959Z Begin collecting coverage...
2022-01-29T17:26:42.6736508Z Loading code coverage from file: coverage/report.json
2022-01-29T17:26:42.6739661Z Collecting coverage ended
2022-01-29T17:26:42.6740133Z Begin parsing coverage...
2022-01-29T17:26:42.6858358Z Parsing coverage ended
2022-01-29T17:26:42.6859052Z Head coverage collection ended
2022-01-29T17:26:42.6859851Z Begin switching to base branch...
2022-01-29T17:26:42.6892856Z [command]/usr/bin/git fetch --all --depth=1
2022-01-29T17:26:42.6966737Z Fetching origin
2022-01-29T17:26:43.0769019Z [command]/usr/bin/git checkout -f main
2022-01-29T17:26:43.0930199Z Previous HEAD position was 99929ce Merge 07f5dca5293ac5c42d72932c790a3bd7b6d706f1 into d5ec4d14968fe2f1b3a6b61457380d503b1e4678
2022-01-29T17:26:43.0931299Z Switched to a new branch 'main'
2022-01-29T17:26:43.0931913Z Branch 'main' set up to track remote branch 'main' from 'origin'.
2022-01-29T17:26:43.0932683Z Switching to base branch ended
2022-01-29T17:26:43.0933460Z Begin base coverage collection...
2022-01-29T17:26:43.0933962Z Begin installing dependencies...
2022-01-29T17:26:43.0934668Z Installing dependencies skipped
2022-01-29T17:26:43.0935129Z Installing dependencies ended
2022-01-29T17:26:43.0936784Z Begin running tests...
2022-01-29T17:26:43.0937167Z Running tests skipped
2022-01-29T17:26:43.0937728Z Running tests ended
2022-01-29T17:26:43.0938285Z Begin collecting coverage...
2022-01-29T17:26:43.0938853Z Loading code coverage from file: coverage/main.json
2022-01-29T17:26:43.0969119Z Collecting coverage ended
2022-01-29T17:26:43.0987225Z Begin parsing coverage...
2022-01-29T17:26:43.1163029Z Parsing coverage ended
2022-01-29T17:26:43.1163370Z Base coverage collection ended
2022-01-29T17:26:43.1163726Z Begin switching back to original branch...
2022-01-29T17:26:43.1210102Z [command]/usr/bin/git fetch --all --depth=1
2022-01-29T17:26:43.1256198Z Fetching origin
2022-01-29T17:26:43.5089447Z [command]/usr/bin/git checkout -f chore/coverage
2022-01-29T17:26:43.5194553Z Switched to a new branch 'chore/coverage'
2022-01-29T17:26:43.5195390Z Branch 'chore/coverage' set up to track remote branch 'chore/coverage' from 'origin'.
2022-01-29T17:26:43.5202367Z Switching back to original branch ended
2022-01-29T17:26:43.5202944Z Begin stages.checkthreshold...
2022-01-29T17:26:43.5457114Z stages.checkThreshold failed
2022-01-29T17:26:43.5475529Z ##[error]TypeError: Reduce of empty array with no initial value
2022-01-29T17:26:43.5476888Z stages.checkThreshold ended
2022-01-29T17:26:43.5477431Z Begin generating report...
2022-01-29T17:26:43.5741060Z Generating report ended
2022-01-29T17:26:43.5741729Z Begin report publish...
2022-01-29T17:26:44.4970658Z Report publish ended
2022-01-29T17:26:44.4972167Z Begin failed tests' annotations publication...
2022-01-29T17:26:44.4972857Z Failed tests' annotations publication skipped
2022-01-29T17:26:44.4973478Z Failed tests' annotations publication ended
2022-01-29T17:26:44.4973992Z Begin coverage annotations publication...
2022-01-29T17:26:44.4974526Z Coverage annotations publication skipped
2022-01-29T17:26:44.4975013Z Coverage annotations publication ended
2022-01-29T17:26:44.4976412Z ##[error]Jest coverage report action failed
2022-01-29T17:26:44.5082782Z ##[error]Process completed with exit code 1.
Expected behavior
Details
- Action version: 2.02
- OS, where your action is running (windows, linux): ubuntu-latest
- uses: dawidd6/action-download-artifact@v2
continue-on-error: true
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: check-code-on-main.yml
workflow_conclusion: success
branch: main
name: coverage
path: coverage
# some steps to run tests typically on head branch, collecting coverage...
- uses: ArtiomTr/[email protected]
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
skip-step: all
annotations: none
coverage-file: ./coverage/report.json
base-coverage-file: ./coverage/main.json
Additional context
Note I am trying to use github artifacts to restore the base coverage file but note it switches branch anyway.
Note I am running in a nx monorepo so I have a small script that combines many jest coverage reports but it seems to be able to calculate coverage fine but failing when doing some directory matching in this action source.
// jest.config.js
const { getJestProjects } = require('@nrwl/jest')
module.exports = {
projects: getJestProjects(),
coverageThreshold: {
global: {
branches: 0,
functions: 0,
lines: 0,
statements: 0,
},
},
}
// jest.preset.js
module.exports = {
collectCoverage: true,
testLocationInResults: true,
collectCoverageFrom: [
'**/*.{ts,tsx}',
'!**/node_modules/**',
'!**/{dist}/**/*',
'!**/*.d.ts',
'!**/service-db/**/*',
],
coverageReporters: ['text', 'text-summary', 'json'],
coverageThreshold: {
global: {
branches: 0,
functions: 0,
lines: 0,
statements: 0,
},
},
}
Hey @chrisui 👋,
I've possibly fixed that issue in #226. This fix is available on v2
or v2.0.3
tag. Could you please confirm, if this fixed your issue?