-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Tidy up tests #294
Tidy up tests #294
Conversation
* Add nyc coverage tool * Remove `env-test`: it's a single line for the cost of a module * Set NODE_ENV in custom set up file * Stub console for each test individually globally * Plus: a `sinon.restore()` in global afterEach prevents cross test leaks * Add most basic test for `Tldr` class, just to trigger coverage * Remove surplus mocha args: * It always looks in test dir * `mocha.opts` provides a more consistent approach * Ignore coverage files now created by nyc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! As far as I'm concerned this is a very nice and useful PR, well done! 👍
I'm leaving it to @agnivade to take a look and merge.
@@ -0,0 +1,11 @@ | |||
process.env.NODE_ENV = 'test'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to mocha.opts
as --env
flag cause that is where people would typically look for it. Add use strict
pragma on the top of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give me the syntax of a --env
flag with mocha? I'm looking for it's documentation and have thrown some stuff at the wall, but nothing seems to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is an --env
flag: mochajs/mocha#185. I am good with this or setting it via a variable in the npm invocation string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me. Great touch on adding the test coverage. Just one minor comment on moving the mocha.opts to a separate config file, since it's going to be deprecated.
Thanks !
test/mocha.opts
Outdated
@@ -1,3 +1,3 @@ | |||
--reporter spec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we are here, can we move from mocha.opts to a config file ? Looks like it is deprecated and will be removed in future: https://mochajs.org/#mochaopts. .mocharc.js
looks fine by me.
@@ -0,0 +1,11 @@ | |||
process.env.NODE_ENV = 'test'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is an --env
flag: mochajs/mocha#185. I am good with this or setting it via a variable in the npm invocation string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful, thank you.
Description
env-test
: it's a single line for the cost of a modulesinon.restore()
in global afterEach prevents cross test leaksTldr
class, just to trigger coverage* It always looks in test dir
*
mocha.opts
provides a more consistent approachChecklist
Please review this checklist before submitting a pull request.
npm run test:all
)