Skip to content

test: add coverage for trailing option set to false#428

Merged
blakeembrey merged 1 commit into
pillarjs:masterfrom
mahmoodhamdi:test/trailing-false-option
Mar 30, 2026
Merged

test: add coverage for trailing option set to false#428
blakeembrey merged 1 commit into
pillarjs:masterfrom
mahmoodhamdi:test/trailing-false-option

Conversation

@mahmoodhamdi

Copy link
Copy Markdown
Contributor

What

Added test cases for the trailing: false option in match(), which previously had no test coverage.

Why

While working with path-to-regexp in an Express API, I noticed the trailing option is documented and supported but had zero test cases when set to false. Every other match option (end, sensitive, decode, delimiter, encodePath) has dedicated test cases covering its behavior.

Tests added

  • Static path (/test): confirms trailing slash is rejected
  • Pattern with trailing slash (/test/): confirms it requires the trailing slash
  • Parameterized path (/:test): verifies params still work correctly
  • Wildcard path (/*path): verifies wildcard captures with trailing delimiter behavior
  • Combined trailing: false + end: false: verifies both options interact correctly
  • Optional group ({/:test}/bar): verifies trailing slash rejection with optional segments

All existing tests continue to pass.

The `trailing` option (which allows optional trailing delimiter) had
no test cases when set to `false`. Added tests covering:
- Simple static paths
- Paths with trailing slash in the pattern
- Parameterized paths
- Wildcard paths
- Combined trailing: false with end: false
- Optional groups with trailing: false
@codecov

codecov Bot commented Mar 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.75%. Comparing base (34cb451) to head (a7314c1).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #428   +/-   ##
=======================================
  Coverage   99.75%   99.75%           
=======================================
  Files           1        1           
  Lines         415      415           
  Branches      156      157    +1     
=======================================
  Hits          414      414           
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 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.

@blakeembrey blakeembrey merged commit 9fd31e0 into pillarjs:master Mar 30, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants