test-reporter
test-reporter copied to clipboard
Vitest junit - Cannot read property 'time' of undefined
Using Vitest I would specify the following configuration for my reporters:
reporters: ['junit'],
outputFile: './report/integration-tests-results.json',
Failed Output:
Using test report parser 'jest-junit'
Creating test report Integration Tests Report
Processing test results from ./report/integration-tests-results.xml
Error: Cannot read property 'time' of undefined
Running into the same problem: https://github.com/IntelliTect/Coalesce/runs/7960417153?check_suite_focus=true
The readme is outdated, the following worked for me.
my action yaml file
name: "tests"
on:
pull_request:
push:
jobs:
build-test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- run: npm ci
- run: npm run test-ci
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: JEST Tests
path: reports/jest-*.xml
reporter: jest-junit
my package.json file
{
// some other stuff...
"scripts": {
"test": "jest",
"test-ci": "jest --ci --reporters=default --reporters=jest-junit"
},
"dependencies": {
"@actions/core": "^1.9.1",
"@actions/exec": "^1.1.1",
"@types/command-exists": "^1.2.0",
"command-exists": "^1.2.9",
"esbuild": "^0.15.6",
"string-argv": "^0.3.1"
},
"devDependencies": {
"@types/jest": "^28.0.0",
"@types/node": "^18.7.9",
"jest": "^28.0.0",
"jest-junit": "^14.0.1",
"jest-junit-reporter": "^1.1.0",
"ts-jest": "^28.0.0",
"typescript": "^4.7.4"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node"
},
"jest-junit": {
"outputDirectory": "reports",
"outputName": "jest-junit.xml",
"ancestorSeparator": " › ",
"uniqueOutputName": "false",
"suiteNameTemplate": "{filepath}",
"classNameTemplate": "{classname}",
"titleTemplate": "{title}"
}
}
#137 & #148 see above ^^
@SamKirkland this issue is about vitest, not jest.
I can't update my process to node 18, is there another solution that uses LTS?
Has anyone found a solution to this? I'm running into the same issue.
+1 on this
+1 on this. I'm guessing this is failing on the root element <testsuites>
missing attributes such as time?
Can the reporter please be updated to check for the attribute truthiness to handle the error a bit more gracefully?
Yes please! According to the spec these attributes are optional, and vitest does not generate them.
Looks like Vitest added support for these attributes here. https://github.com/vitest-dev/vitest/commit/d050604f1995b53e1b70b32bee821f01ad3e0797