Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocha discourages arrow functions in tests #297

Closed
wkw opened this issue Apr 12, 2016 · 8 comments
Closed

Mocha discourages arrow functions in tests #297

wkw opened this issue Apr 12, 2016 · 8 comments
Labels

Comments

@wkw
Copy link
Contributor

wkw commented Apr 12, 2016

Just getting started with first FJS project. Was working on initial tests this morning and ran into this while trying to increase a test's timeout:

Passing arrow functions to Mocha is discouraged.
Their lexical binding of the this value makes them unable to access the Mocha context, and statements like this.timeout(1000); will not work inside an arrow function.

https://mochajs.org/#arrow-functions

Are there any arguments for sticking with Arrow functions for generated tests?

@daffl
Copy link
Member

daffl commented Apr 12, 2016

Not really, it is probably a good idea to change it back to normal functions as they suggest. If you have the time, a pull request changing the test files in https://github.com/feathersjs/generator-feathers/tree/master/generators would be awesome.

@wkw
Copy link
Contributor Author

wkw commented Apr 12, 2016

OK, I'll take a look through the genies and try to get a suitable PR put together.
Be good to have a little involvement with the project.

@wkw
Copy link
Contributor Author

wkw commented Apr 12, 2016

@daffl any advice on how I tell Yeoman to use my modified generators for testing the changes? I've only dealt with Yo as a user and not even that often.

@daffl
Copy link
Member

daffl commented Apr 12, 2016

In the generator repository run npm link. Then any calls to yo feathers:* will use that linked repository. For those changes you can also just run npm test to see if they are still all passing.

@daffl daffl added the Proposal label Apr 13, 2016
wkw pushed a commit to wkw/generator-feathers that referenced this issue Apr 16, 2016
wkw pushed a commit to wkw/generator-feathers that referenced this issue Apr 16, 2016
@wkw
Copy link
Contributor Author

wkw commented Apr 16, 2016

One thing that stumped me after I first updated the generated tests was that none of the non-transform tests were succeeding, all for exit codes not being zero. I eventually added a console.log to show the tmp dir path so I could go in and run the tests directly on the generated app. It was jshint complaining about semicolons. Seems like there should be a way to pipe those jshint failures to the output so it's clearer why the test failed. I'm not sure how that would be accomplished, but would gladly take pointers and work up another PR.

daffl added a commit to feathersjs-ecosystem/generator-feathers that referenced this issue Apr 16, 2016
@daffl
Copy link
Member

daffl commented Apr 16, 2016

Thanks a lot for the PR! I noticed, too that there wasn't a lot of error reporting when the app test command fails so I added feathersjs-ecosystem/generator-feathers@f006e4d to the tests. Now we should get an error with the full output of the test run.

I'm going to close this issue and will make a new release of the generator shortly.

@daffl daffl closed this as completed Apr 16, 2016
@wkw
Copy link
Contributor Author

wkw commented Apr 16, 2016

@daffl I saw your commit earlier for the better error reporting and of course had to try it out. Perfect!

daffl added a commit that referenced this issue Aug 25, 2018
Pass fewer arrow functions to Mocha. #297
@lock
Copy link

lock bot commented Feb 7, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants