Skip to content

feat: enable testing of provided types with .toBeCallableWith()#593

Merged
mrazauskas merged 9 commits intomainfrom
testing-types-toBeCallableWith
Sep 23, 2025
Merged

feat: enable testing of provided types with .toBeCallableWith()#593
mrazauskas merged 9 commits intomainfrom
testing-types-toBeCallableWith

Conversation

@mrazauskas
Copy link
Member

Partly #592

Currently .toBeCallableWith() can only test inferred types of expressions. This change enables testing of provided types as well:

import { expect, test } from "tstyche";

type FormFieldGetter = <T, K extends keyof T>(form: T, field: K) => T[K];

const userForm = {
  name: "Alice",
  email: "alice@example.com",
};

test("FormFieldGetter", () => {
  expect<FormFieldGetter>().type.toBeCallableWith(userForm, "name");
  expect<FormFieldGetter>().type.toBeCallableWith(userForm, "email");

  expect<FormFieldGetter>().type.not.toBeCallableWith(userForm, "age");
});

@codacy-production
Copy link

codacy-production bot commented Sep 22, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.05% (target: -1.00%) 96.88% (target: 85.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (93e05d0) 6693 6617 98.86%
Head commit (b0b668a) 6698 (+5) 6625 (+8) 98.91% (+0.05%)

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 (#593) 32 31 96.88%

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 merged commit 59db320 into main Sep 23, 2025
22 checks passed
@mrazauskas mrazauskas deleted the testing-types-toBeCallableWith branch September 23, 2025 08:30
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