Mocha tests: Missing function expression name. (func-names)
See original GitHub issueWhen writing Mocha tests, it is not possible to use fat arrow functions because we sometimes need to use the this
keyword to change the test’s timeout for example.
describe('some description', function () {
before('blabla', function () {
this.timeout(10000);
return somePromise();
});
});
This results in the following eslint error:
Missing function expression name. (func-names)
I was wondering what was the guidelines for this case. Naming the functions is out of the question as it would add a lot of noise.
Issue Analytics
- State:
- Created 8 years ago
- Comments:16
Top Results From Across the Web
Warning Unexpected unnamed function func-names under ...
ESLint is complaining about this line, which is indeed an expression, not an assignment or function call: !hash[curr.farmerId] && (hash[curr ...
Read more >func-names - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Mocha - the fun, simple, flexible JavaScript test framework
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun. Mocha tests run ......
Read more >How to test JavaScript with Mocha — Part 2 - codeburst
We're going to test to ensure these functions are working nicely. Here's the structure I see our test.js file taking: A testing group...
Read more >ValidateJavaScript - Online Tool to Find & Fix JavaScript Errors
func-names func-style function-call-argument-newline function-paren-newline generator-star-spacing getter-return ... no-unused-expressions no-unused-labels
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
Using arrow functions in mocha tests is discouraged according to their official documentation.
I just don’t really see the point for mocha tests and it goes against the DRY principle. e.g.
Anyways, I added
func-names: 0
to mytests/.eslintrc
.