Skip to content

Update tests to be more resilient against assert message changes in Node core #10111

@not-an-aardvark

Description

@not-an-aardvark

Our tests for RuleTester currently make assertions about the error messages that RuleTester outputs. These tests have been broken a few times in the past due to changes in the error messages created by Node's assert module (e.g. #9688, nodejs/node#19467 (comment)). Having the tests break is generally inconvenient (among other things, Node runs the eslint tests as part of citgm in order to detect regressions), so we should try to make these tests more robust.

One way to do it would be to dynamically generate an expected error message as part of the test. For example, we could replace the code here:

assert.throws(() => {
    ruleTester.run(/* ... */)
}, /Bad var\.((.*==)|(.*strictEqual)).*Bad error message/);

...with something like this:

const nodeAssert = require("assert");

assert.throws(() => {
    ruleTester.run(/* ... */)
}, new nodeAssert.AssertionError({ actual: "Bad var.", expected: "Bad error message", operator: "===" }).message);

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionchoreThis change is not user-facinggood first issueGood for people who haven't worked on ESLint before

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions