FYI for Vitest 4 users #7951
Replies: 3 comments
-
|
I think we could have an option to keep function expressions if they're passed to a .mockImplementation() call. |
Beta Was this translation helpful? Give feedback.
-
|
For those affected by the issue: Instead of turning off the rule completely, you can use named functions for the mock implementations. Named function expressions are ignored by Example: myMock.mockImplementation(function someArbitraryName() {
return 'value';
});But yes, it would be nice, if Biome could handle anonymous functions too in this case. |
Beta Was this translation helpful? Give feedback.
-
|
As another workaround, you can add type annotation for the myMock.mockImplementation(function (this: MyClass) {
return 'value';
}); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Vitest 4 recently came out, and it's now extremely sensitive to when you can use arrow functions vs normal functions. The linter rule
complexity.useArrowFunctionneeds to be turned tooffwhen using Vite 4 so it does not convert the normal functions to arrow functions.https://main.vitest.dev/guide/migration.html#spyon-and-fn-support-constructors
Not sure what an appropriate fix for this would be...
Beta Was this translation helpful? Give feedback.
All reactions