Skip to content

Invalid toThrow verification #6805

@vitaly-t

Description

@vitaly-t

🐛 Bug Report

.toThrow() fails to check correctly against an empty string or a string with one symbol.

To Reproduce

it('must fail when compared against an empty string', () => {
    expect(() => {
        throw 'something';
     }).toThrow(''); // PASS
});

it('must fail against a string with one letter', () => {
    expect(() => {
        throw 'something';
     }).toThrow('a'); // PASS
});

Expected behavior

The two cases above are supposed to fail. But instead, they both succeed.

Curiously, if in the second case we use more than one letter, only then the test fails.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions