Skip to content

test: use the .test.ts suffix for test files - #17

Merged
milamer merged 1 commit into
mainfrom
test/test-file-suffix
Nov 9, 2026
Merged

milamer merged 1 commit into
mainfrom
test/test-file-suffix

Conversation

@milamer

@milamer milamer commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Follow-up to #16. No change to src/ code or the package; test: doesn't release.

Changes

  • Renamed the test files in src/__tests__/ (pure renames, so git log --follow and blame still work):
    • index.ts → index.test.ts
    • path-parts.ts → path-parts.test.ts
    • properties.ts → properties.test.ts
    • utils.ts (shared helpers) and types.test-d.ts keep their names.
  • vitest.config.mts: include is now src/**/__tests__/**/*.test.ts. The exclude list for utils.ts and *.test-d.ts is gone because neither matches any more. vitest's default excludes still apply, since exclude isn't set.
  • knip.json: added src/**/*.test-d.ts to entry. When vitest's test.include is set, knip's vitest plugin uses it as the test entries instead of its default patterns (which include *.test-d.ts). The old **/*.ts pattern happened to cover the type tests; the new one doesn't, so knip reported types.test-d.ts as unused.

Why

The include pattern used to match every .ts file in __tests__, so every non-test file needed an exclude entry. A new helper file would have run as an empty test file. With a suffix, the config only says what a test is. .test.ts is vitest's default naming and matches the .test-d.ts type tests.

npm run validate passes: still 3 test files and 316 tests, 100% coverage, knip clean.

Rename the test files in src/__tests__ to *.test.ts and include only
that suffix in vitest. Helpers (utils.ts) and type tests (*.test-d.ts)
no longer match, so the exclude list is gone.

knip uses vitest's include as its test entries when it's set, so it
stopped seeing types.test-d.ts and reported it as unused. Add it to
knip's entry list.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (37e9d29) to head (c000197).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #17   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          134       134           
  Branches        45        45           
=========================================
  Hits           134       134           

☔ 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.

@milamer
milamer merged commit 13119f1 into main Nov 9, 2026
7 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