Skip to content

test(signals): refactor to Vitest type tests - #5127

Open
santoshyadavdev wants to merge 6 commits into
ngrx:mainfrom
santoshyadavdev:migrate-to-expectTypeOf
Open

test(signals): refactor to Vitest type tests#5127
santoshyadavdev wants to merge 6 commits into
ngrx:mainfrom
santoshyadavdev:migrate-to-expectTypeOf

Conversation

@santoshyadavdev

@santoshyadavdev santoshyadavdev commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Closes #

What is the new behavior?

uses expectTypeOf for type testing, this closed #4935 partially

Does this PR introduce a breaking change?

[ ] Yes
[ ] No

Other information

@netlify

netlify Bot commented Mar 25, 2026

Copy link
Copy Markdown

Deploy Preview for ngrx-io ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 3ff684b
🔍 Latest deploy log https://app.netlify.com/projects/ngrx-io/deploys/69d3182d5c248d0008076900
😎 Deploy Preview https://deploy-preview-5127--ngrx-io.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread modules/signals/spec/types/patch-state.types.spec.ts Outdated

@rainerhahnekamp rainerhahnekamp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@santoshyadavdev. Looks reasonable to me at first sight. Still have to check it thoroughly, but it seems we will settle down with a combination of @ts-expect-error and Vitest type assertions?

@santoshyadavdev

Copy link
Copy Markdown
Contributor Author

@santoshyadavdev. Looks reasonable to me at first sight. Still have to check it thoroughly, but it seems we will settle down with a combination of @ts-expect-error and Vitest type assertions?

Yes you are right, I will fix some pending code and linter soon

@mrazauskas

Copy link
Copy Markdown

Do I get it right that pnpm exec nx test signals should run the updated tests? Hm.. I tried adding obviously failing line (like const a: number = "abc") to modules/signals/spec/types/signal-state.types.spec.ts. Running the command reports all tests passing. Or did I misunderstood something?

@rainerhahnekamp Would be be still interested to check out TSTyche? (Based on #4935 (comment)). I could put together a similar PR. One of the advantages, there would be no need for @ts-expect-error directives, that cast too wide a net (in type testing context). Because any errors in the following line are suppressed.

@rainerhahnekamp rainerhahnekamp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick update from my side. I'd like to go through each test manually first because these are our lifesavers. I don't expect any issues, but I want to be 100% safe.

@timdeschryver timdeschryver left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks @santoshyadavdev !
I left some comments with the differences between the old and new tests.

@rainerhahnekamp fyi, I wasn't aware of it, but the @ts-expect-error messages are not tested. This isn't blocking for me, but on the other hand this might give false confidence in the tests. That's why I'm fine with removing the message in these test cases.

Comment thread modules/signals/spec/types/signal-state.types.spec.ts Outdated
Comment thread modules/signals/spec/types/signal-store.types.spec.ts Outdated
Comment thread modules/signals/spec/types/signal-state.types.spec.ts
Comment thread modules/signals/spec/types/signal-store.types.spec.ts Outdated
@rainerhahnekamp

Copy link
Copy Markdown
Contributor

@timdeschryver

I wasn't aware of it, but the @ts-expect-error messages are not tested. This isn't blocking for me,

I was aware. @mrazauskas pointed that out in his PR's description #5128 (comment). It isn't a blocker for me either and I am fine if we remove the messages to avoid misunderstandings.

@santoshyadavdev santoshyadavdev changed the title update signal test to use vitest expectTypeOf test(signals): update signal test to use vitest expectTypeOf Apr 6, 2026
@santoshyadavdev

Copy link
Copy Markdown
Contributor Author

@rainerhahnekamp let me know if I need to do anything on this, if you can merge this one I can work on next issue

@rainerhahnekamp

Copy link
Copy Markdown
Contributor

@santoshyadavdev we do have a few issues with type tests. I was researching for some time and have a proposal on how we align our tests more to Vitest's defaults. Will be update you soon.

@santoshyadavdev

Copy link
Copy Markdown
Contributor Author

@santoshyadavdev we do have a few issues with type tests. I was researching for some time and have a proposal on how we align our tests more to Vitest's defaults. Will be update you soon.

@rainerhahnekamp sounds good, meanwhile I will check if I can pickup something, thank you

@timdeschryver timdeschryver changed the title test(signals): update signal test to use vitest expectTypeOf test(signals): refactor to Vitest type tests Jun 13, 2026
@rainerhahnekamp

Copy link
Copy Markdown
Contributor

Alright @santoshyadavdev, sorry for the delay, but we are now ready. The type tests will really fail if they are not type-safe. Can you please rebase on main?

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.

Replace ts-snippet

4 participants