platform icon indicating copy to clipboard operation
platform copied to clipboard

wip(store): migrate testing suite from jest to vitest

Open exequiel09 opened this issue 1 month ago • 6 comments

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/ngrx/platform/blob/main/CONTRIBUTING.md#commit
  • [ ] Tests for the changes have been added (for bug fixes / features)
  • [ ] Documentation has been added / updated (for bug fixes / features)

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
[x] Other... Please describe:

Updates to testing to ensure compatibility to `vitest`

What is the current behavior?

The current behavior is that tests are running perfectly fine on jest. This PR ensures that it runs smoothly on vitest without any errors.

Closes #5018

What is the new behavior?

No new behavior. Just ensures to maintain parity when it runs using vitest

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

exequiel09 avatar Dec 02 '25 05:12 exequiel09

Deploy Preview for ngrx-io canceled.

Built without sensitive environment variables

Name Link
Latest commit 5a52eb9ca7258e90829f2d0eb00f67fd0491a0f7
Latest deploy log https://app.netlify.com/projects/ngrx-io/deploys/6940f654402ed400088c6cff

netlify[bot] avatar Dec 02 '25 05:12 netlify[bot]

Deploy Preview for ngrx-site-v19 ready!

Name Link
Latest commit 5a52eb9ca7258e90829f2d0eb00f67fd0491a0f7
Latest deploy log https://app.netlify.com/projects/ngrx-site-v19/deploys/6940f656d707bb0008778e30
Deploy Preview https://deploy-preview-5036--ngrx-site-v19.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.

netlify[bot] avatar Dec 02 '25 05:12 netlify[bot]

Only type errors are left which I didn't touch and just appeared when migrated to vitest.

  1. https://github.com/ngrx/platform/actions/runs/19849232805/job/56872554303?pr=5036#step:8:407 (should handle undefined value for the reducer?)
  2. https://github.com/ngrx/platform/actions/runs/19849232805/job/56872554303?pr=5036#step:8:382 (needs to be rewritten??)

Culprit for item 1: Screenshot 2025-12-02 at 2 59 37 PM

Thinking of how to fix this 🤔

  • fix option 1 = add https://vitest.dev/config/dangerouslyignoreunhandlederrors.html to project-wide(store) vite config 🤷🏻
  • fix option 2 = suppress error in each it block by using uncaughtException handler to filter the noisy error. Might be okay to create a test helper function to suppress error (similar to this https://gist.github.com/exequiel09/3eb99dfcdcfbc0d1fdb3bef4d538d79d)
  • fix option 3 = add project-wide (store) uncaughtException handler and filter errors there which will became an unwieldy list of false-positive of errors

exequiel09 avatar Dec 02 '25 06:12 exequiel09

Would love to ask for some feedback on the PR @markostanimirovic and @brandonroberts especially on the issues that arised upon migrating to vitest. Thank you.

exequiel09 avatar Dec 02 '25 10:12 exequiel09

Hi @timdeschryver would love also your feedback here. Just a couple issues then I think it's good to go. Thank you.

exequiel09 avatar Dec 07 '25 16:12 exequiel09

Hi @timdeschryver would love also your feedback here. Just a couple issues then I think it's good to go. Thank you.

I will take a look at it later this week (probably at the end of it)

timdeschryver avatar Dec 08 '25 19:12 timdeschryver

The failing type tests can be fixed by updating the timeout to 8_000 within the describe block (this will be passed down to each test case), similar to what's done in #5044.

Addressed this in https://github.com/ngrx/platform/pull/5036/commits/35b9962c71e83374ffcb7139fab8f590f918a6de

exequiel09 avatar Dec 15 '25 01:12 exequiel09

The remaining CI errors are not caused by this PR => they should be resolved in #5044.

There are 2 errors that's related to vitest uncaught exceptions.

  1. I mentioned in this comment as problem item 1 (https://github.com/ngrx/platform/pull/5036#issuecomment-3600383044) which is reflected as well in this CI run (https://github.com/ngrx/platform/actions/runs/20217503698/job/58033009122?pr=5036#step:8:2150) Screenshot 2025-12-15 at 9 25 42 AM

  2. I mention in this comment as problem item 2 (https://github.com/ngrx/platform/pull/5036#issuecomment-3600383044) which is reflected as well in this CI run (https://github.com/ngrx/platform/actions/runs/20217503698/job/58033009122?pr=5036#step:8:2127) Screenshot 2025-12-15 at 9 27 12 AM

From looking at the PR, I think you addressed all of the issues yourself, or is there still something left where you're waiting for input?

@timdeschryver I was looking for inputs on how to resolve this. Also, I tried to propose solutions in the comment (https://github.com/ngrx/platform/pull/5036#issuecomment-3600383044), that needs to be discussed since the solutions I have thought of might not be up to the team's liking.

exequiel09 avatar Dec 15 '25 01:12 exequiel09

The remaining CI errors are not caused by this PR => they should be resolved in #5044.

There are 2 errors that's related to vitest uncaught exceptions.

  1. I mentioned in this comment as problem item 1 (wip(store): migrate testing suite from jest to vitest #5036 (comment)) which is reflected as well in this CI run (https://github.com/ngrx/platform/actions/runs/20217503698/job/58033009122?pr=5036#step:8:2150)
Screenshot 2025-12-15 at 9 25 42 AM 2. I mention in this comment as problem item 2 ([wip(store): migrate testing suite from jest to vitest #5036 (comment)](https://github.com/ngrx/platform/pull/5036#issuecomment-3600383044)) which is reflected as well in this CI run (https://github.com/ngrx/platform/actions/runs/20217503698/job/58033009122?pr=5036#step:8:2127) Screenshot 2025-12-15 at 9 27 12 AM > From looking at the PR, I think you addressed all of the issues yourself, or is there still something left where you're waiting for input?

@timdeschryver I was looking for inputs on how to resolve this. Also, I tried to propose solutions in the comment (#5036 (comment)), that needs to be discussed since the solutions I have thought of might not be up to the team's liking.

Oh sorry, I missed those comments while reviewing. The latest commit should resolve these, the only failing ones are not store related and shouldn't be addressed in this PR. We can publish the PR and I'll review it once more with a fresh head, I suppose it's good to be merged though.

timdeschryver avatar Dec 15 '25 12:12 timdeschryver

We can publish the PR and I'll review it once more with a fresh head, I suppose it's good to be merged though.

Hey @timdeschryver I removed the "draft" status and changed the title to use the type refactor instead of wip.

exequiel09 avatar Dec 15 '25 12:12 exequiel09

@exequiel09 could you pull the latest main branch into your branch please? This should resolve the remaining errors.

timdeschryver avatar Dec 16 '25 06:12 timdeschryver

I just rebased the PR just moments ago based on the latest commits on the main branch. Did something change again or got merged?

exequiel09 avatar Dec 16 '25 06:12 exequiel09

I just rebased the PR just moments ago based on the latest commits on the main branch. Did something change again or got merged?

Thanks 👍 You can ignore my comment then.

timdeschryver avatar Dec 16 '25 06:12 timdeschryver

I just rebased the PR just moments ago based on the latest commits on the main branch. Did something change again or got merged?

Checked. PR is still on top of the commits of main branch.

Screenshot 2025-12-16 at 2 57 42 PM Screenshot 2025-12-16 at 2 58 54 PM

exequiel09 avatar Dec 16 '25 06:12 exequiel09

I see one of the issues exceeded 8000ms. That's why something failed.

https://github.com/ngrx/platform/actions/runs/20258235781/job/58164627027?pr=5036#step:8:1558 Screenshot 2025-12-16 at 3 00 16 PM

exequiel09 avatar Dec 16 '25 07:12 exequiel09