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

mocking date for a test to ensure pad2 runs with single digit dates #226

Closed

Conversation

ryhinchey
Copy link
Contributor

@ryhinchey ryhinchey commented Feb 27, 2020

This PR adds a test to always make sure pad2 is covered. When running tests, if every value passed to pad2 is two digits (which depends on the time the tests are run), a drop in coverage can happen.

To mock the date I added sinon@2.0.0. as a dependency. 2.0.0 was used as it was an older version that I hoped would work in older versions of node

test/morgan.js Outdated
Comment on lines 215 to 217
var GlobalDate = global.Date

global.Date = function () { return new GlobalDate('2020-02-27') }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not proud of this but sinon did not play nice with node 0.8 or 0.10 https://travis-ci.org/expressjs/morgan/builds/655979079

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants