Skip to content

Expected behavior: expect(() => { throw undefined }).toThrow('Input validation failed') should fail. #7260

@unnoq

Description

@unnoq

Describe the bug

Encountered unexpected behavior where throwing undefined still passed the tests. This occurred because I created a mock function meant to check the error before throwing, but I forgot to implement the check.

Expected behavior: expect(() => { throw undefined }).toThrow('Input validation failed') should fail.

Reproduction

Expected behavior: expect(() => { throw undefined }).toThrow('Input validation failed') should fail.

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    Memory: 2.06 GB / 7.57 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
    pnpm: 9.15.2 - ~/.nvm/versions/node/v22.12.0/bin/pnpm
  Browsers:
    Chrome: 131.0.6778.264
  npmPackages:
    @vitest/coverage-v8: ^2.1.1 => 2.1.8 
    vitest: ^2.1.8 => 2.1.8

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)upstream

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions