Skip to content

More granularity for error types? #76

Closed
@DmitrySharabin

Description

@DmitrySharabin

I have a test that passes, even though I expect it to fail:

{
  run () {
    throw new SyntaxError();
  },
  throws: TypeError,
}

I know that both SyntaxError and TypeError are subclasses of the Error class, and according to our docs and the code we have in our codebase, this test should (and does) pass. But should it?

I found a way to get the granularity I need:

{
  run () {
    throw new SyntaxError();
  },
  throws: (error) => error.constructor === TypeError;
}

Is this the right/expected way to get what I need?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions