Skip to content

Conversation

@aarongoldenthal
Copy link
Contributor

@aarongoldenthal aarongoldenthal commented Jul 20, 2025

The current test scripts single quote the test pattern glob, which runs properly in Linux and macOS, but on Windows it results in no tests found. This then passes since no tests failed, as seen in the following log from here.

Actions Log
Run npm test

> [email protected] test
> npm run test-coverage && npm run verify-coverage && npm run test-integration

> [email protected] test-coverage
> nyc --reporter=text --reporter=html mocha --file test/unit/setup.test.js 'test/unit/**/*.test.js' --recursive

Warning: Cannot find any files matching pattern "'test/unit/**/*.test.js'"

  0 passing (1ms)

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------

> [email protected] verify-coverage
> nyc check-coverage --lines 90 --functions 90 --branches 90

Warning: Cannot find any files matching pattern "'test/integration/**/*.test.js'"
> [email protected] test-integration
> mocha --file test/integration/setup.test.js 'test/integration/**/*.test.js' test/integration/teardown.test.js --recursive --timeout 20000 --slow 5000

  0 passing (0ms)

This traces back to the original conversion from make to npm scripts in 40ba01a, with the note "quote globs in scripts to avoid missingsubdirectories". On Linux/macOS without the quotes, or with double quotes, the tests/unit/lib/reporters/* tests are not run, although on Windows the tests all run in those cases. Mocha was updated in #256 (from 10.3.0 to 11.1.0), and this appears to have been missed (tests run as expected in the previous commit).

Keeping the globs, double quoted, but without the --recursive flag seems to work on all platforms. I also added the --fail-zero flag, which will fail if no tests are found.

This appears to be an instance of mochajs/mocha#4186.

@aarongoldenthal aarongoldenthal marked this pull request as ready for review July 20, 2025 22:09
@aarongoldenthal aarongoldenthal force-pushed the fix-test-scripts-windows branch from bb58cca to ba6734d Compare July 20, 2025 22:20
@aarongoldenthal aarongoldenthal added this to the 4.0.0 milestone Jul 21, 2025
@aarongoldenthal aarongoldenthal mentioned this pull request Jul 21, 2025
9 tasks
Copy link
Contributor

@jpw jpw left a comment

Choose a reason for hiding this comment

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

Nice spot and fix, thanks @aarongoldenthal :)

@aarongoldenthal aarongoldenthal merged commit 0414ed2 into main Jul 21, 2025
13 checks passed
@aarongoldenthal aarongoldenthal deleted the fix-test-scripts-windows branch July 21, 2025 16:02
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.

3 participants