profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/DaJoTo/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

DaJoTo/BetterReflection 0

:crystal_ball: Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in reflection API.

issue commenttesting-library/eslint-plugin-testing-library

[prefer-explicit-assert] Incomplete expect statement causes TypeError

@Belco90 awesome that you got that patched so quickly. Thank you

DaJoTo

comment created time in 5 days

issue openedtesting-library/eslint-plugin-testing-library

Incomplete expect statement breaks causes TypeError

Plugin version

4.12.2

ESLint version

7.32.0

Node.js version

15.11.0

npm/yarn version

yarn 1.22.10

Operating system

macOS Big Sur, version 11.6

Bug description

Leaving an incomplete expect statement with the prefer-explict-assert rule active breaks the linter.

Steps to reproduce

  • configure the prefer-explicit-assert rule to be active
  • write a basic test which includes expect('something');
  • see that the linter fails with a TypeError

Error output/screenshots

Oops! Something went wrong! :(                                                                                   
                                                                                                                         
ESLint: 7.32.0                                                                                                           
                                                                                                                         
TypeError: Cannot read property 'name' of undefined
Occurred while linting [...]/components/OverrideSummary.test.tsx:1
    at [...]/node_modules/eslint-plugin-testing-library/rules/prefer-explicit-assert.js:124:48
    at Array.forEach (<anonymous>)
    at Object.Program:exit ([...]/node_modules/eslint-pluging-testing-library/rules/prefer-explicit-assert.js:105:31)
    at enhancedRuleInstructions.<computed> ([...]/node_modules/eslint-plugin-testing-library/create-testing-library-rule/detect-testing-library-utils.js:518:105)
    at [...]/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit ([...]/node_modules/eslint/lib/linter/safe-emitter.js:45:38)                                                          
    at NodeEventGenerator.applySelector ([...]/node_modules/eslint/lib/linter/node-event-generator.js:293:26)
    at NodeEventGenerator.applySelectors ([...]/node_modules/eslint/lib/linter/node-event-generator.js:322:22)
    at NodeEventGenerator.leaveNode ([...]/node_modules/eslint/lib/linter/node-event-generator.js:345:14)
error Command failed with exit code 2.

ESLint configuration

module.exports = { parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint', 'jsx-a11y', 'no-only-tests'], extends: [ 'react-app', 'plugin:react/recommended', 'plugin:@typescript-eslint/recommended', 'plugin:jsx-a11y/recommended', 'plugin:prettier/recommended', 'prettier/@typescript-eslint', 'prettier/react', ], parserOptions: { ecmaVersion: 6, project: ['./tsconfig.json', './cypress/tsconfig.json'], sourceType: 'module', ecmaFeatures: { jsx: true, }, }, settings: { react: { version: 'detect', }, }, rules: { '@typescript-eslint/explicit-module-boundary-types': 0, 'require-await': 0, '@typescript-eslint/no-inferrable-types': 1, }, overrides: [ { files: ['cypress/**/.ts'], extends: ['plugin:cypress/recommended'], rules: { 'cypress/no-unnecessary-waiting': 'warn', }, }, { files: ['.test.ts', '*.test.tsx'], extends: ['plugin:testing-library/react', 'plugin:jest-dom/recommended'], rules: { 'no-console': 'off', 'testing-library/no-debug': 'warn', 'testing-library/prefer-explicit-assert': ['error', { assertion: 'toBeInTheDocument' }], 'testing-library/render-result-naming-convention': 'warn', }, }, ], };

Rule(s) affected

prefer-explicit-assert

Anything else?

No response

Do you want to submit a pull request to fix this bug?

Yes, but need help

created time in 9 days