`no-useless-undefined`: `undefined` removed from jest function matchers
See original GitHub issuetest('function called with different parameters that could be undefined', () => {
expect(someFunction).toHaveBeenCalledWith(1, 2, 3);
expect(someFunction).toHaveBeenCalledWith(1, undefined, 3);
expect(someFunction).toHaveBeenCalledWith(1, 2, undefined);
});
This is breaking as jest toHaveBeenCalledWith (and other similar matchers) explicitly checks for nth argument to be undefined
Would be better if this rule would accept and array of “acceptable” functions that have undefined?
Issue Analytics
- State:
- Created 3 years ago
- Comments:11
Top Results From Across the Web
no-useless-undefined - should not be fixable #760 - GitHub
As it stands, the rule corrects console.log(undefined) to console.log(). ... no-useless-undefined : undefined removed from jest function ...
Read more >Jest Mock returns undefined instead of value - Stack Overflow
I am trying to mock a function from other dependency. The function from dependency should return an array, but it is showing undefined...
Read more >Checking for null and undefined - Testing React Apps with ...
The unhappy path for this function returns undefined . In data.getCompany.test.js, add a test for the getCompany unhappy path using the toBeUndefined matcher....
Read more >sindresorhus/eslint-plugin-unicorn (Raised $2856.00)
`no-useless-undefined`: `undefined` removed from jest function matchers. Unfunded#807created bydanut-t. $0.00. Rule proposal: `no-native-addon-dependencies`.
Read more >@cling/eslint-config - npm
ESLint configuration for @cling related packages. Latest version: 1.7.0, last published: a year ago. Start using @cling/eslint-config in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Essentially it’s a unsolvable problem but I guess a allowlist of common usages of
undefined
is a bandaid fix that might ease the pain in some cases. Still I have the rule disabled and would not recommend enabling it 😉.Yap, the simplest way to fix this is add this name to that list.