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

Wrong error location in json report #1894

Closed
6 tasks done
marilari88 opened this issue Aug 21, 2022 · 0 comments
Closed
6 tasks done

Wrong error location in json report #1894

marilari88 opened this issue Aug 21, 2022 · 0 comments

Comments

@marilari88
Copy link

Describe the bug

Running vitest with reporter=json option, it produces a JSON output with a wrong error location. It seems that it doesn't take into account of source map corresponding position.
It negatively affects with tools that use that position to show the user which assertion is causing the test to fail. (Eg. the neotest adapter I'm working on https://github.com/marilari88/neotest-vitest)

Reproduction

https://stackblitz.com/edit/node-zkm2qe?file=test/basic.test.ts

Running npm test --reporter=json it will produce the piece of JSON below reporting for the first test the wrong line and column

...  
 "assertionResults": [
        {
          "ancestorTitles": [
            ""
          ],
          "fullName": " Math.sqrt()",
          "status": "failed",
          "title": "Math.sqrt()",
          "duration": 23,
          "failureMessages": [
            "expected 3.7416573867739413 to equal 12"
          ],
          "location": {
            "line": 5,
            "column": 32
          }
        },

The location should have line = 10

System Info

System:
    OS: Linux 5.17 Manjaro Linux
    CPU: (16) x64 AMD Ryzen 7 PRO 4750U with Radeon Graphics
    Memory: 6.96 GB / 14.86 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.18 - /sbin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
  Browsers:
    Firefox: 103.0
  npmPackages:
    @vitejs/plugin-react: ^2.0.0 => 2.0.0 
    vite: ^3.0.0 => 3.0.4 
    vitest: ^0.20.2 => 0.20.3

Used Package Manager

yarn

Validations

@github-actions github-actions bot locked and limited conversation to collaborators Jun 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants