Definition for rule 'testing-library/await-async-events' was not found

200 Views Asked by At

I'm trying to follow along with the docs. But when I run my linter, I'm getting these 5 "definition for rule was not found" error in my test files. Any clue to what's going on?

  1:1  error  Definition for rule 'testing-library/await-async-events' was not found      testing-library/await-async-events
  1:1  error  Definition for rule 'testing-library/await-async-queries' was not found     testing-library/await-async-queries
  1:1  error  Definition for rule 'testing-library/no-await-sync-queries' was not found   testing-library/no-await-sync-queries
  1:1  error  Definition for rule 'testing-library/no-render-in-lifecycle' was not found  testing-library/no-render-in-lifecycle
  1:1  error  Definition for rule 'testing-library/prefer-implicit-assert' was not found  testing-library/prefer-implicit-assert

Packages:

    "@testing-library/jest-dom": "5.17.0",
    "@testing-library/react": "^12.1.5",
    "@testing-library/user-event": "14.4.3",
    "eslint": "^8.55.0",
    "eslint-plugin-jest": "^27.2.1",
    "eslint-plugin-jest-dom": "5.0.2",
    "eslint-plugin-react": "7.33.1",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-testing-library": "^5.11.1",
    "events": "^3.3.0",
    "jest": "29.6.2",
    "jest-config": "29.6.2",
    "jest-environment-jsdom": "29.6.2",
    "jest-sonar-reporter": "^2.0.0",

ESLint Config:

module.exports = {
  plugins: ['jest', 'react-hooks'],
  extends: ['plugin:react/recommended', 'plugin:@typescript-eslint/recommended'],
  overrides: [
    /**
     * Enable eslint-plugin-testing-library rules or preset only for matching testing files!
     */  
    {
      files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
      extends: ['plugin:testing-library/react'],
      rules: {
        /**
         * Testing library
         */
        // prefer-presence-queries
        'testing-library/prefer-presence-queries': 'error',
        // Ensure appropriate get*/query* queries are used with their respective matchers

        // await-async-events
        'testing-library/await-async-events': [
          2,
          {
            "eventModule": ["fireEvent", "userEvent"]
          }
        ],
        // Enforce promises from async event methods are handled

        // await-async-queries
        'testing-library/await-async-queries': 'error',
        // Enforce promises from async queries to be handled
        
        // await-async-utils
        'testing-library/await-async-utils': 'error',
        // Enforce promises from async utils to be awaited properly
        
        // consistent-data-testid
        'testing-library/consistent-data-testid': [
          2, 
          {
            'testIdPattern': '^[a-z]+[A-Z][a-zA-Z0-9]*$'
          }
        ],
        // Ensures consistent usage of data-testid
        
        // no-await-sync-events
        'testing-library/no-await-sync-events': 'error',
        // Disallow unnecessary await for sync events
        
        // no-await-sync-queries
        'testing-library/no-await-sync-queries': 'error',
        // Disallow unnecessary await for sync queries
        
        // no-container
        'testing-library/no-container': 'warn',
        // Disallow the use of container methods
        
        // no-promise-in-fire-event
        'testing-library/no-promise-in-fire-event': 'error',
        // Disallow the use of promises passed to a fireEvent method
        
        // no-render-in-lifecycle
        'testing-library/no-render-in-lifecycle': 'error',
        // Disallow the use of render in testing frameworks setup functions
        
        // no-unnecessary-act
        'testing-library/no-unnecessary-act': 'error',
        // Disallow wrapping Testing Library utils or empty callbacks in act
        
        // no-wait-for-multiple-assertions
        'testing-library/no-wait-for-multiple-assertions': 'error',
        // Disallow the use of multiple expect calls inside waitFor
        
        // no-wait-for-side-effects
        'testing-library/no-wait-for-side-effects': 'error',
        // Disallow the use of side effects in waitFor
        
        // no-wait-for-snapshot
        'testing-library/no-wait-for-snapshot': 'error',
        // Ensures no snapshot is generated inside of a waitFor call
        
        // prefer-explicit-assert
        'testing-library/prefer-explicit-assert': 'error',
        // Suggest using explicit assertions rather than standalone queries
        
        // prefer-find-by
        'testing-library/prefer-find-by': 'error',
        // Suggest using find(All)By* query instead of waitFor + get(All)By* to wait for elements
        
        // prefer-implicit-assert
        'testing-library/prefer-implicit-assert': 'error',
        // Suggest using implicit assertions for getBy* & findBy* queries
        
        // prefer-presence-queries
        'testing-library/prefer-presence-queries': 'error',
        // Ensure appropriate get*/query* queries are used with their respective matchers
        
        // prefer-query-by-disappearance
        'testing-library/prefer-query-by-disappearance': 'error',
        // Suggest using queryBy* queries when waiting for disappearance
        
        // prefer-query-matchers
        'testing-library/prefer-query-matchers': 'error',
        // Ensure the configured get*/query* query is used with the corresponding matchers
        
        // prefer-screen-queries
        'testing-library/prefer-screen-queries': 'error',
        // Suggest using screen while querying
        
        // prefer-user-event
        'testing-library/prefer-user-event': 'warn',
        // Suggest using userEvent over fireEvent for simulating user interactions
        
        // render-result-naming-convention
        'testing-library/render-result-naming-convention': 'error',
        // Enforce a valid naming for return value from render
      }
        },
  ]

I've tried adding and removing plugins: ['testing-library'] to see if that was missing. I've tried reinstalling the related packages. Tried following along similarly related Stack Overflow questions with no avail.

0

There are 0 best solutions below