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

Tidy up tests #294

Merged
merged 5 commits into from
Apr 27, 2020
Merged

Tidy up tests #294

merged 5 commits into from
Apr 27, 2020

Conversation

OiYouYeahYou
Copy link
Contributor

Description

  • 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

Checklist

Please review this checklist before submitting a pull request.

  • Code compiles correctly
  • Created tests, if possible
  • All tests passing (npm run test:all)
  • Extended the README / documentation, if necessary

* 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
Copy link
Collaborator

@vladimyr vladimyr left a 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';
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

@agnivade agnivade left a 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
Copy link
Member

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';
Copy link
Member

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.

Copy link
Member

@agnivade agnivade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful, thank you.

@agnivade agnivade merged commit d4fcbc2 into tldr-pages:master Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants