Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): switch to vitest #10362

Closed
wants to merge 6 commits into from
Closed

Conversation

Josh-Walker-GM
Copy link
Collaborator

@Josh-Walker-GM Josh-Walker-GM commented Mar 29, 2024

This PR updated the @redwoodjs/core package to use vitest instead of jest for the unit testing.

This one is a little more crazy than the others due to some things I've had to work around. As a result it also switches out the build process for this package to use esbuild like our other packages. This was needed to ensure I could avoid certain syntax in the code to allow testing but ultimately still build the same dist that is shipped to users.

It passes CI just fine and I of course did adhoc local testing too.

@Josh-Walker-GM Josh-Walker-GM added release:chore This PR is a chore (means nothing for users) changesets-ok Override the changesets check labels Mar 29, 2024
@Josh-Walker-GM Josh-Walker-GM added this to the chore milestone Mar 29, 2024
@Josh-Walker-GM Josh-Walker-GM self-assigned this Mar 29, 2024
@peterp
Copy link
Contributor

peterp commented May 11, 2024

@Josh-Walker-GM This looks like it passed CI, any large considerations to take before we merge this?

@Josh-Walker-GM Josh-Walker-GM modified the milestones: chore, next-release May 11, 2024
@Josh-Walker-GM Josh-Walker-GM marked this pull request as ready for review May 11, 2024 13:40
@Josh-Walker-GM
Copy link
Collaborator Author

@Josh-Walker-GM This looks like it passed CI, any large considerations to take before we merge this?

@peterp Nope I think it's good to go now. I've fixed the conflicts and such. If it passes CI this time I'll be happy for it to get merged. Want to sanity check and approve it before I merge?

@peterp
Copy link
Contributor

peterp commented May 11, 2024

Yup! Awesome! I'll check this out and wrap my head around it!

packages/core/build.mts Show resolved Hide resolved
@@ -0,0 +1,21 @@
import { build, defaultBuildOptions } from '@redwoodjs/framework-tools'

// Build 'dist/bins'
Copy link
Member

Choose a reason for hiding this comment

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

Nit-picky for sure, but aren't we actually building src/bins (and outputting to dist/bins)?

Copy link
Member

Choose a reason for hiding this comment

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

It is just because you added an import that we now need to build? Can you use require instead, so we don't have to build?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm happy to correct the comment.

Vitest doesn't natively intercept require which means if we still want to use require we'd need to look to some additional library. I think I'd rather build the files - keeps the source style consistent with the rest of the code and no additional dependency we're not already familiar with. See: vitest-dev/vitest#3134.

As we're getting increasingly close to removing webpack this test and so the need for vitest at all in this package will go away.

Copy link
Member

Choose a reason for hiding this comment

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

Right. I forgot about vitest not working with require natively. Building makes sense. Then my next questions/suggestion/idea is: Can we build to dist/config instead? But still not include it in release of course.

@Josh-Walker-GM
Copy link
Collaborator Author

No longer needed after #10867

@Josh-Walker-GM Josh-Walker-GM deleted the jgmw-chore/core-vitest branch July 19, 2024 16:34
@Josh-Walker-GM Josh-Walker-GM removed this from the next-release milestone Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changesets-ok Override the changesets check release:chore This PR is a chore (means nothing for users)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants