chore: migrate test runner from mocha to jest#2567
chore: migrate test runner from mocha to jest#2567maverick1872 merged 41 commits intowinstonjs:masterfrom
Conversation
4e45ba7 to
dead87b
Compare
|
Appreciate the effort but this is not the direction the project is interested in going. Similar PRs that consider tap or the built-in node.js test runner would be considered. Thanks! |
|
Philosophically I am a minimalist w.r.t. software design patterns & API surfaces (see: Robustness principal, also known as "Postel's law"). This philosophy is deeply embedded into the history & design of Node.js itself. That said, those values must be balanced carefully with those that value volunteers like yourself @maverick1872 who step up to help in Keeping Important Code Alive, [SeattleJS 2015] Before tools like I realized this morning that This would have taken weeks if not months in the past. All of this taken together has leads me to retract my previous objections @maverick1872 as long as we have a shared understanding as maintainers that we may revisit this decision in the future as it is now relatively trivial to accomplish. |
6a4aac7 to
10dcb6d
Compare
|
@indexzero @DABH do either of you know if coveralls can inform you as to where the coverage decrease occurred? Looks like it's most likely a byproduct of the consolidation of the File Transport tests. Happy to just undo the refactor but figured consolidation would ease some maintenance and clarity of what the tests are doing. |
|
@maverick1872 Yeah just click the three dots next to the coverage/coveralls line in the little PR check area on this page and then click View Details. It should take you to the Coveralls site which lists individual files and their coverage changes you can look at. Thank you so much for the attention to detail here. Feel free to @ me when the PR is ready for review :) |
jest intercepts stderr and pipes it to stdout. As such this test needed to make it's assertions on that of console.error invocations instead. Practically speaking these tests shouldn't even be necessary as this repo no longer maintains the transport implementations.
6d550d8 to
926ec37
Compare
|
@DABH @indexzero feel free to review when/if desired. I know it's large so I would advocate looking to the summary in the PR description which should hopefully make it clear what all has been done. Happy to have a more involved discussion/provide reasoning on any of my choices if desired. |
There was a problem hiding this comment.
Pull Request Overview
This PR migrates Winston's test suite from Mocha to Jest, modernizing the testing infrastructure to provide enhanced testing capabilities and improved developer experience.
- Converted all test files from Mocha syntax (
before,after,this.timeout()) to Jest equivalents (beforeAll,afterAll,jest.setTimeout()) - Consolidated redundant file transport tests into a single comprehensive test file with improved organization
- Updated CI configuration and documentation to reflect the new Jest-based testing approach
Reviewed Changes
Copilot reviewed 36 out of 38 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
test/unit/winston/winston.test.js |
New comprehensive test file moved from integration, testing Winston's public API |
test/unit/winston/transports/file.test.js |
Consolidated and modernized file transport tests with comprehensive coverage |
test/unit/winston/transports/http.test.js |
Updated timeout syntax for Jest compatibility |
test/unit/winston/logger.test.js |
Enhanced with new test cases and Jest-compatible error handling |
test/unit/winston/log-exception.test.js |
Modernized exception handling tests with async/await patterns |
package.json |
Updated dependencies and scripts to use Jest instead of Mocha |
.github/workflows/ci.yml |
Updated CI pipeline for Jest-based testing workflow |
Comments suppressed due to low confidence (4)
test/unit/winston/winston.test.js:24
- [nitpick] The parameter name 'opts' is ambiguous. Consider renaming to 'options' for better clarity.
});
DABH
left a comment
There was a problem hiding this comment.
I'm ok with this once you've appeased Copilot's comments. Thanks again for your efforts here!
|
@maverick1872 Sorry for creating merge conflicts for you with the package files but feel free to resolve and finish this off at your convenience :) |
Hadn't realized this was approved. Should be able to address this weekend and move this forward. |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 36 out of 38 changed files in this pull request and generated 6 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| /* | ||
| * logger-test.js: Tests for instances of the winston Logger | ||
| * | ||
| * (C) 2010 Charlie Robbins | ||
| * MIT LICENSE | ||
| * | ||
| */ |
There was a problem hiding this comment.
The filename comment at the top refers to 'logger-test.js' but the actual file is 'winston.test.js'. This should be updated for consistency.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 36 out of 38 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…licit it expects undefined
|
@DABH PR wrapped up; all comments addressed. Figured was straight forward enough to do now while I was thinking about it. Will merge tomorrow evening unless I hear otherwise. |
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [winston](https://github.com/winstonjs/winston) | [`3.18.3` -> `3.19.0`](https://renovatebot.com/diffs/npm/winston/3.18.3/3.19.0) |  |  | --- ### Release Notes <details> <summary>winstonjs/winston (winston)</summary> ### [`v3.19.0`](https://github.com/winstonjs/winston/releases/tag/v3.19.0) [Compare Source](winstonjs/winston@v3.18.3...v3.19.0) - Run npm audit fix [`e7ccdc4`](winstonjs/winston@e7ccdc4) - Don't include jest.config.js in npm package [`5a63c8c`](winstonjs/winston@5a63c8c) - fix: append error cause when using `logger.child()` ([#​2467](winstonjs/winston#2467)) [`e74a7ae`](winstonjs/winston@e74a7ae) - Bump rimraf from 5.0.1 to 5.0.10 ([#​2517](winstonjs/winston#2517)) [`8a956fd`](winstonjs/winston@8a956fd) - fix: ensure File transport flushes all data before emitting finish ([#​2594](winstonjs/winston#2594)) [`86c890f`](winstonjs/winston@86c890f) - Bump actions/setup-node from 4 to 6 ([#​2589](winstonjs/winston#2589)) [`3b8be02`](winstonjs/winston@3b8be02) - Bump [@​babel/core](https://github.com/babel/core) from 7.28.0 to 7.28.5 ([#​2591](winstonjs/winston#2591)) [`f4c3e2c`](winstonjs/winston@f4c3e2c) - Bump actions/checkout from 4 to 6 ([#​2593](winstonjs/winston#2593)) [`dd7906e`](winstonjs/winston@dd7906e) - chore: migrate test runner from mocha to jest ([#​2567](winstonjs/winston#2567)) [`2e9eb18`](winstonjs/winston@2e9eb18) *** </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4yNy4xIiwidXBkYXRlZEluVmVyIjoiNDIuMjcuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Reviewed-on: https://git.foxden.network/FoxDen/carvera-pendant/pulls/39 Co-authored-by: Renovate <renovate@foxden.network> Co-committed-by: Renovate <renovate@foxden.network>
Migrate Winston Test Suite from Mocha to Jest
This PR fully migrates Winston's test suite from Mocha to Jest to provide a more fully featured testing framework
Warning
The File Transport tests while passing in their current form, illustrate in my opinion
some potential issues in how it currently functions.
FIX:comments on a couple of assertions that I presume are correct but are currently failing.maxsizeandlazyoptions result in behavior I found unexpected. e.g. If the rotation is not lazy, it will drop a log file resulting in 1 less populated log file than I would expectSummary
before(),after(),this.timeout()tobeforeAll(),afterAll(), andjest.setTimeout()winston.test.jsfromintegrationtounit. This felt more appropriate given the contents of the test.console.errorintegrationsuite given they're actually writing files to the FS.Test Plan