Skip to content

Repo: rule-tester's eslint-base test failing on main #9011

Closed
@auvred

Description

@auvred

Suggestion

Coming here from #8995 (comment)

Note: the rule-tester package is not currently being tested in CI (see #9005)

Running cd packages/rule-tester; yarn run test-eslint-base produces the following errors:


  RuleTester
    1) "before each" hook for "should not throw an error when everything passes"


  0 passing (15ms)
  1 failing

  1) RuleTester
       "before each" hook for "should not throw an error when everything passes":
     Error: Missing definition for `afterAll` - you must set one using `RuleTester.afterAll` or there must be one defined globally as `afterAll`.
      at Function.get afterAll [as afterAll] (src/TestFramework.ts:66:11)
      at new RuleTester (src/RuleTester.ts:102:17)
      at Context.<anonymous> (tests/eslint-base/eslint-base.test.js:110:22)
      at processImmediate (node:internal/timers:478:21)
  112 passing (327ms)
  1 pending
  24 failing

...

  2) RuleTester
       should throw an error when the error message regex does not match:
     AssertionError: expected [Function] to throw error matching /Expected 'Bad var.'…/Bad error message\ but got 'sourceCode is not defined\nOccurred w…'
      at Context.<anonymous> (tests/eslint-base/eslint-base.test.js:444:16)
      at processImmediate (node:internal/timers:478:21)

...

  24) RuleTester
       naming test cases
         should use the test code as the name if the "name" property is set to an empty string:
     ReferenceError: sourceCode is not defined
Occurred while linting file.ts:1
Rule: "foo"
      at VariableDeclaration (tests/eslint-base/fixtures/no-var.js:16:30)

...


The fix for this issue should go hand-in-hand with #9005 and #8969

Ideally (I guess) we should sync tests/eslint-base/eslint-base.test.js and tests/eslint-base/fixtures/* with upstream, because tests/eslint-base/**/* was intentionally copied from ESLint repo without any changes to verify that forked RuleTester is still compatible with ESLint's RuleTester.

The following changes were made to RuleTester's tests since #6777:
https://github.com/eslint/eslint/commits/main/tests/lib/rule-tester/rule-tester.js?since=2023-04-27&until=2024-04-27

The following changes were made to RuleTester's tests fixtures since #6777:
https://github.com/eslint/eslint/commits/main/tests/fixtures/testers/rule-tester?since=2023-04-27&until=2024-04-27


Btw, fun fact: today is the one year anniversary of the PR (#6777) that added RuleTester to this repo 🎉🎉🎉

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