Skip to content

fix: only reject positional args that are entirely numeric - #6222

Merged
mark-wiemer merged 1 commit into
mochajs:mainfrom
lazerg:fix/issue-6221-numeric-prefixed-spec-file
Sep 6, 2026
Merged

fix: only reject positional args that are entirely numeric#6222
mark-wiemer merged 1 commit into
mochajs:mainfrom
lazerg:fix/issue-6221-numeric-prefixed-spec-file

Conversation

@lazerg

@lazerg lazerg commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

Overview

isNumeric checks its input with parseFloat, which stops at the first character that cannot be part of a number. A spec file whose name starts with a digit, like npx mocha 1-spec.js, therefore counts as a numeric positional and the CLI bails out with Option NaN is unsupported by the mocha cli.

Comparing against Number instead makes the check look at the whole string, so bare numbers such as mocha 123 still error while file names that merely begin with a digit run as before.

Note that #6221 is still in triage rather than labelled accepting prs, so feel free to close this if you want to discuss it first.

@github-actions

This comment has been minimized.

@mark-wiemer mark-wiemer added this to Mocha Sep 2, 2026
@mark-wiemer

Copy link
Copy Markdown
Member

Looks good, let's wait for tests to pass and also backport this to v11

@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.08%. Comparing base (505b5e9) to head (43f8c28).
⚠️ Report is 34 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6222      +/-   ##
==========================================
- Coverage   81.93%   74.08%   -7.85%     
==========================================
  Files          64       65       +1     
  Lines        4866     5669     +803     
  Branches     1100     1337     +237     
==========================================
+ Hits         3987     4200     +213     
- Misses        879     1469     +590     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mark-wiemer
mark-wiemer merged commit 1633779 into mochajs:main Sep 6, 2026
153 of 154 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Mocha Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

🐛 Bug (v12): spec file stating with a number rejected

2 participants