Skip to content

Unintended consequence of internal-only stack trace override #9837

@chet-manley

Description

@chet-manley

💥 Regression Report

When creating custom matchers that throw exceptions on invalid arguments, the displayed stack trace goes all the way back to the matcher definition, where the error is thrown. The resulting console output highlights where the throw occurred within the matcher definition, instead of which expect failed within the test. I traced this behavior back to #5162, where default behavior was changed to only match errors with matcher[INTERNAL_MATCHER_FLAG] set to true. Currently (v25.x), this appears to be handled here.

Last working version

I'm not sure what version master was at when the PR was merged, but it appears to be 21 or 22.

To Reproduce

  • Create an external matcher that throws an exception when provided invalid argument(s).
  • Call matcher with invalid argument(s).

Expected behavior

Console output should be the same as what is displayed when an internal matcher fails an argument check.

Link to repl or repo (highly encouraged)

repl.it demo

Run npx envinfo --preset jest

  System:
    OS: Linux 5.5 Fedora 31 (Workstation Edition) 31 (Workstation Edition)
    CPU: (4) x64 Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
  Binaries:
    Node: 13.13.0 - /usr/bin/node
    npm: 6.14.4 - /usr/bin/npm
  npmPackages:
    jest: ^25.3.0 => 25.3.0

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