absolute-version / commit-and-tag-version

Fork of the excellent standard-version. Automate versioning and CHANGELOG generation, with semver.org and conventionalcommits.org :trophy:
ISC License
360 stars 33 forks source link

test: Re-work tests to use Jest and not mockery and mock-fs #119

Closed TimKnight-DWP closed 8 months ago

TimKnight-DWP commented 8 months ago

Fixes #118

Because mock-fs creates a fake Filesystem in memory I had to do a lot of changes to core.spec.js to re-work both the mocking and verification to make use of Jest spies instead.

codecov-commenter commented 8 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (16be049) 97.65% compared to head (1d799a0) 94.42%.

Files Patch % Lines
jest.config.js 0.00% 2 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #119 +/- ## ========================================== - Coverage 97.65% 94.42% -3.23% ========================================== Files 32 25 -7 Lines 1362 466 -896 ========================================== - Hits 1330 440 -890 + Misses 32 26 -6 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

TimothyJones commented 8 months ago

I was trying to work out why it failed but didn't have any output, and then saw the --silent 😅

TimKnight-DWP commented 8 months ago

Heh - yeah, there was a really weird bug in the mocking of gitSemverTags for how the callback was working 🙈

And because of some weirdness in clearing out the stderr logs, some of the tests failed due to earlier tests spitting something naff into the logs

TimothyJones commented 8 months ago

I know this isn't passing yet, but it's looking really nice - it seems like a clear readability improvement to me.

TimKnight-DWP commented 8 months ago

Thanks, I feel like I'm inching towards getting git tests working, thought doing core.spec would have been the hardest, but run into a subtle difference between looking at stdout.error compared to spying on console (in that console.warn ends up in stdouterror which threw me off for a bit when trying to look in console.error calls for certain logs)

TimKnight-DWP commented 8 months ago

@TimothyJones - okay that should be pretty much done, going to come back with fresh eyes in the morning and check there aren't any verifications I can improve now I have a better understanding of testing exceptions and errors printed to console.warn

TimothyJones commented 8 months ago

Awesome! I’ll review this evening (in about 8 hours) and we can get this in. Thank you so much!

TimKnight-DWP commented 8 months ago

Awesome - sounds like my morning will roughly align with your evening 👍

TimKnight-DWP commented 8 months ago

Removed the upper limit and now run tests always against the current lts and latest versions published by node - should give us more heads up of breakages, working versions, with less manual effort to add more checks for specific versions

TimKnight-DWP commented 8 months ago

Right - all assertions/verification are the same or as close as possible to where they were before. And running on LTS (20.9) and Latest (21)

Good to go 👍

TimKnight-DWP commented 8 months ago

fyi I won't be in on this again til Monday, in case you've got any change requests, just to set expectations so you know not to look at it after comments until next week 😄