Skip to content

Tests: RuleTester tests contains outdated snapshot with incorrect test case filename #9732

Closed
@auvred

Description

@auvred

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

rule-tester

Expected Result

Run

$ cd packages/rule-tester; yarn run test

without any errors.

Actual Result

$ cd packages/rule-tester; yarn run test
PASS tests/flat-config-schema.test.ts
FAIL tests/RuleTester.test.ts
  ● RuleTester › filenames › automatically sets the filename for tests

    expect(received).toMatchInlineSnapshot(snapshot)

    Snapshot name: `RuleTester filenames automatically sets the filename for tests 1`

    - Snapshot  - 1
    + Received  + 6

    @@ -17,11 +17,16 @@
            },
          },
        },
        {
          "code": "explicit filename shouldn't be overwritten",
    -     "filename": "/set/in/the/test.ts",
    +     "filename": "/some/path/that/totally/exists/set/in/the/test.ts",
    +     "languageOptions": {
    +       "parserOptions": {
    +         "disallowAutomaticSingleRunInference": true,
    +       },
    +     },
        },
        {
          "code": "jsx should have the correct filename",
          "filename": "/some/path/that/totally/exists/react.tsx",
          "languageOptions": {

      192 |       });
      193 |
    > 194 |       expect(getTestConfigFromCall()).toMatchInlineSnapshot(`
          |                                       ^
      195 |         [
      196 |           {
      197 |             "code": "string based valid test",

      at Object.toMatchInlineSnapshot (tests/RuleTester.test.ts:194:39)

 › 1 snapshot failed.
Snapshot Summary
 › 1 snapshot failed from 1 test suite. Inspect your code changes or run `yarn run npx -u` to update them.

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 failed, 51 passed, 52 total
Snapshots:   1 failed, 8 passed, 9 total
Time:        1.622 s, estimated 2 s
Ran all test suites.

The most interesting part is:

    -     "filename": "/set/in/the/test.ts",
    +     "filename": "/some/path/that/totally/exists/set/in/the/test.ts",

Additional Info

rule-tester package is not currently being tested in CI (see #9005). That's why this issue was unnoticed.


After bisecting, it turns out that this test case doesn't work after #9678.

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.testsanything to do with testing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions