Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
auvred opened this issue Aug 6, 2024 · 2 comments · Fixed by #9746
Closed
4 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. tests anything to do with testing

Comments

@auvred
Copy link
Member

auvred commented Aug 6, 2024

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.

@auvred auvred added bug Something isn't working triage Waiting for team members to take a look labels Aug 6, 2024
@kirkwaiblinger kirkwaiblinger added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Aug 6, 2024
@auvred auvred changed the title Bug: RuleTester overwrites explicitly specified test case filename Tests: RuleTester tests contains outdated snapshot with incorrect test case filename Aug 7, 2024
@auvred auvred added tests anything to do with testing and removed bug Something isn't working labels Aug 7, 2024
@auvred
Copy link
Member Author

auvred commented Aug 7, 2024

UPD: I misinterpreted this test failure! There is no bug in the rule tester. It's all about an outdated snapshot in the test.

@JoshuaKGoldberg
Copy link
Member

phew

@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Aug 15, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. tests anything to do with testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants