Skip to content

Repo: handle exceptions that occur while testing a rule better #8942

Closed
@kirkwaiblinger

Description

@kirkwaiblinger

Suggestion

If you throw an exception in a rule (within the RuleListener object handlers, not at the top level of the create() function), the whole test suite fails with an unhelpful error message, rather than failing just the individual test run and printing a useful error message. For instance, here's what happens when I throw an exception in a line affected by just one test case:

 FAIL  tests/rules/no-unnecessary-type-arguments.test.ts
  ● Test suite failed to run

    TypeError: Converting circular structure to JSON
        --> starting at object with constructor 'Object'
        |     property 'params' -> object with constructor 'Array'
        |     index 0 -> object with constructor 'Object'
        --- property 'parent' closes the circle
        at stringify (<anonymous>)

@JoshuaKGoldberg has a hacky workaround. Feel free to share in case that makes it easier to pinpoint the root cause?

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.repo maintenancethings to do with maintenance of the repo, and not with code/docs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions