question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prefer-to-have-value having unintended effects

See original GitHub issue
  • eslint-plugin-jest-dom version: 3.5.0
  • node version: 10.22.0
  • npm version: 6.14.6

Relevant code or config

const gen = someGeneratorFunction();
expect(gen.next().value).toEqual(someYieldedValue);

What you did: ^

What happened: Prefer .toHaveValue() over other attribute checks

Problem description: The new rule prefer-to-have-value is causing unintended warnings when checking the value key on objects that are not DOM elements.

Suggested solution: I’m not sure if there’s a graceful solution that can allow for triggering warnings on element.value but not on obj.value (let me know if I’m wrong!). But I think a reasonable middle ground would be to allow a configuration option to only trigger a warning on expect(element).toHaveAttribute('value', 'someValue') so I don’t have to individually turn off the rule everywhere I’m testing generators.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
juzerzarifcommented, Dec 2, 2020

@benmonro That would be the best of both worlds, sounds like the way to go! I can mess around with it and see about a PR this weekend

1reaction
benmonrocommented, Dec 4, 2020

doh, yes it was a mis-click sorry

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint-plugin-jest-dom/prefer-to-have-value.md at main - GitHub
This rule is an autofixable rule that encourages the use of toHaveValue over checking the value attribute. Rule Details. This rule checks for...
Read more >
Documentation - React Test
toHaveValue (). Checks whether the element has the given value. Only works for input, textarea, and select tags. For input types of checkbox ......
Read more >
You Always Have Value -- Here's How to Nurture It
You are always a valuable, worthwhile human being – not because anybody says so, not because you're suc.
Read more >
Ethics Exam 3: Quizzes Flashcards - Quizlet
If you think something is valuable, we can see it in your actions because you will act on the reasons it gives you....
Read more >
Intrinsic vs. Extrinsic Value
Most philosophers who have written on the question of what has intrinsic value have not been hedonists; like Plato and Aristotle, they have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found