Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vitest junit - Cannot read property 'time' of undefined #187

Open
snowmead opened this issue Aug 22, 2022 · 10 comments
Open

Vitest junit - Cannot read property 'time' of undefined #187

snowmead opened this issue Aug 22, 2022 · 10 comments

Comments

@snowmead
Copy link

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
@ascott18
Copy link

Running into the same problem: https://github.com/IntelliTect/Coalesce/runs/7960417153?check_suite_focus=true

@SamKirkland
Copy link

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}"
  }
}

@SamKirkland
Copy link

#137 & #148 see above ^^

@ascott18
Copy link

ascott18 commented Sep 3, 2022

@SamKirkland this issue is about vitest, not jest.

@Dottenpixel
Copy link

I can't update my process to node 18, is there another solution that uses LTS?

@justin-mclaren
Copy link

Has anyone found a solution to this? I'm running into the same issue.

@Gentatsu
Copy link

Gentatsu commented Feb 8, 2023

+1 on this

@richardeschloss
Copy link

+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?

@blowsie
Copy link

blowsie commented Apr 13, 2023

Yes please! According to the spec these attributes are optional, and vitest does not generate them.

@blowsie
Copy link

blowsie commented Apr 13, 2023

Looks like Vitest added support for these attributes here.
vitest-dev/vitest@d050604

v0.25.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants