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

toThrow does not show a diff with actual result #3941

Closed
6 tasks done
FeldrinH opened this issue Aug 13, 2023 · 0 comments · Fixed by #3979
Closed
6 tasks done

toThrow does not show a diff with actual result #3941

FeldrinH opened this issue Aug 13, 2023 · 0 comments · Fixed by #3979

Comments

@FeldrinH
Copy link

FeldrinH commented Aug 13, 2023

Describe the bug

Using expect(..).toThrow(Error) the error shown on failure is simply expected error to be instance of Error. This contains very little useful info because it does not say what the actual error was or if an error was thrown at all.

I would have expected toThrow to have an output similar to to.throw, which provides a very detailed diff of the expected and actual errors.

Reproduction

test('simplerror', async () => {
    expect(async () => {}).toThrow(Error)
});

outputs

AssertionError: expected error to be instance of Error
...

instead of a detailed diff like to.error does.

System Info

  System:
    OS: Windows 10 10.0.19045
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i5-13600KF
    Memory: 19.28 GB / 31.83 GB
  Binaries:
    Node: 18.15.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.5.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.2.0 - ~\AppData\Local\pnpm\pnpm.EXE
  npmPackages:
    vitest: ^0.34.1 => 0.34.1
  Browsers:
    N/A

Used Package Manager

npm

Validations

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

Successfully merging a pull request may close this issue.

2 participants