Repository navigation
fix: match literal substrings in toIncludeRepeated - #994
Merged
keeganwitt merged 2 commits intoNov 25, 2026
Merged
keeganwitt merged 2 commits into
keeganwitt merged 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 21675a1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #994 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 80 80
Lines 914 911 -3
Branches 341 339 -2
=========================================
- Hits 914 911 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
Thanks for the PR! |
Contributor
Author
|
Thanks @keeganwitt for the review, for adding the |
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.
What
Escape regular expression metacharacters in the substring passed to
toIncludeRepeated. Add regression tests, clarify the literal matching behavior in the documentation, and include a patch changeset.Why
Closes #195.
The matcher documents a string substring, but currently constructs a regular expression from it. For example,
expect('a..').toIncludeRepeated('.', 2)fails because the dot also matchesa, while a substring such as[throws a regular expression syntax error. These inputs now count literal, non-overlapping occurrences. Existing empty-substring behavior is preserved.Notes
Validation on Windows with Node.js 24.14.1, Yarn 4.19.0, and the unchanged lockfile (Jest 30.5.2):
yarn test:coverage --runInBand: 79 suites, 914 tests, and 359 snapshots passed; all coverage thresholds remain at 100%.yarn build,yarn typecheck, and Prettier checks for the changed files passed. The built package also passed 16 assertions covering eight substring cases through Jest'sexpect.yarn lintpassed with the repository's LF bytes for the unchangedvitest.d.mts. The default Windows checkout reports the same 15 CRLF formatting errors before and after this change. The file was restored after validation and is not changed in this PR.yarn test:vitestwith npm 11.20.0: 13 Vitest 5 tests passed; TypeScript Bundler/NodeNext checks, native ESM/CommonJS loading, and rejection of invalid matcher usage passed.The other Node.js/Jest/OS matrix combinations and the Docusaurus website build were not run.
AI assistance was used to investigate the issue, implement the change and tests, and run the checks described above.
Housekeeping