Repository navigation
test: use the .test.ts suffix for test files - #17
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #16. No change to
src/code or the package;test:doesn't release.Changes
src/__tests__/(pure renames, sogit log --followand blame still work):index.ts→index.test.tspath-parts.ts→path-parts.test.tsproperties.ts→properties.test.tsutils.ts(shared helpers) andtypes.test-d.tskeep their names.vitest.config.mts:includeis nowsrc/**/__tests__/**/*.test.ts. The exclude list forutils.tsand*.test-d.tsis gone because neither matches any more. vitest's default excludes still apply, sinceexcludeisn't set.knip.json: addedsrc/**/*.test-d.tstoentry. When vitest'stest.includeis set, knip's vitest plugin uses it as the test entries instead of its default patterns (which include*.test-d.ts). The old**/*.tspattern happened to cover the type tests; the new one doesn't, so knip reportedtypes.test-d.tsas unused.Why
The include pattern used to match every
.tsfile 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.tsis vitest's default naming and matches the.test-d.tstype tests.npm run validatepasses: still 3 test files and 316 tests, 100% coverage, knip clean.