Skip to content

feat: add the structure-based implementation of the .toBe() matcher#636

Merged
mrazauskas merged 11 commits intomainfrom
structure
Dec 17, 2025
Merged

feat: add the structure-based implementation of the .toBe() matcher#636
mrazauskas merged 11 commits intomainfrom
structure

Conversation

@mrazauskas
Copy link
Member

@mrazauskas mrazauskas commented Dec 16, 2025

Adding structure-based implementation of the .toBe() matcher.

Current implementation is patch-based. It is not perfect and also it will not work in TypeScript 7. Which means: this work removes the last blocker to support TypeScript 7 (reference #443). This is exciting!

The new structure-based implementation brings in several improvements. For instance, it considers the following types as identical:

  • { a: string } & { b: number }, { b: number } & { a: string } and { a: string; b: number }
  • ((a: string) => string) & ((b: number) => number) and { (a: string): string; (b: number): number }

The above works with any complexity and at any depth. This is even more exciting!

The new implementation will be enabled by default. There is a lot of code, obviously. Overall, it does a great job, but there might be some defects, of course. To use the old patch-based implementation of the '.toBe()' matcher, set the "legacyToBe": true option.

@codacy-production
Copy link

codacy-production bot commented Dec 16, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.15% (target: -1.00%) 97.86% (target: 85.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (9b75376) 6749 6678 98.95%
Head commit (cad1e8f) 7301 (+552) 7213 (+535) 98.79% (-0.15%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#636) 562 550 97.86%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@mrazauskas mrazauskas changed the title feat: add the structure-based implementation .toBe() matcher feat: add the structure-based implementation of the .toBe() matcher Dec 17, 2025
@mrazauskas mrazauskas merged commit f57b840 into main Dec 17, 2025
23 checks passed
@mrazauskas mrazauskas deleted the structure branch December 17, 2025 14:04
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.

1 participant