75lb / command-line-args

A mature, feature-complete library to parse command-line options.
MIT License
679 stars 108 forks source link

Update testing infrastructure; swap out test-runner for jest, fix coverage, and update Node support #133

Open zanerock opened 3 days ago

zanerock commented 3 days ago

test-runner -> jest and fix coverage

The test-runner project does not seem to be under active development and command-line-rep is currently using an even older version (0.5) that the 2 year old version (0.10). Also, despite trying for an hour, I couldn't get the nyc coverage generation tool to work with test-runner.

  1. Update the tests. The swap to jest is pretty simple. Simply remove the import TestRunner from 'test-runner' and const runner = new TestRunner(). Then change runner.test to test and everything is ready to go.
  2. Update the packages. Remove the test-runner package and add the latest jest.
  3. Add jest.config.mjs.
  4. Update the scripts. Update test:js, test:mjs, and cover to use jest.

As a bonus, the true coverage is revealed at 94%!

Update Node support.

There's an outstanding PR that shows node 4 and 6 breaking with 8 unknown. The actual report isn't available, but these are really old versions and support can probably be dropped.

  1. Update the GitHub CI. I removed 4, 6, and 8, 10, and 12 and added 18, 20, and 22, and adjusted the 14 to ^14.15.x and 16 to ^16.10.x. 14.15 and 16.10 are the lowest versions supported by Jest v29.
  2. Updat the package.json engines specification to match the CI testing. From "node": ">=4.0 to "node": "^10 || ^12 || ^14.15.x || ^16.10.x || ^17 || ^18 || ^20 || ^22". There may be more to Node support strategy.
75lb commented 2 days ago

Hi.. it's unlikely this project's test suite will migrate to Jest for several reasons but I agree it could do with a general refresh - will look into it.

zanerock commented 1 day ago

I might be able to take a crack at it if you have a set of constraints. I would have spent more time getting the existing system working, but it just seemed like the test-runner project had run out of steam.

75lb commented 1 day ago

I love the fact you're willing to put the work in but yes, just give me some time to refresh the library first so you're not working against outdated code. Yes, there are constraints mainly revolving around stability (this is a Top 1% most-depended-on npm library that has been stable for a decade). Another constraint is minimalism - supporting just the baseline, core requirements whilst enabling extension and personalisation. I'll get back to you.