statelyai / xstate

Actor-based state management & orchestration for complex app logic.
https://stately.ai/docs
MIT License
27.21k stars 1.26k forks source link

switch from jest to vitest #5022

Open with-heart opened 3 months ago

with-heart commented 3 months ago

This PR switches our test setup from jest to vitest.

How it's configured

vitest.workspace.json defines our workspaces as ["packages/*"]. vitest looks for a vitest.config file in each workspace and uses it to run that workspace's tests. This allows each workspace to define the plugins (like vite-plugin-solid for @xstate/solid) and test configuration used to run that workspace's tests.

This allows us to run tests for specific workspaces using vitest --project <package name> (vitest --project @xstate/react).

Major changes

changeset-bot[bot] commented 3 months ago

⚠️ No Changeset found

Latest commit: 8cf97419ac0368885774b2b1cd07e1bb1c49d493

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

davidkpiano commented 3 months ago

I'd like to block this on updating the VS Code launch.json script. It's essential to my workflow.

Extra questions:

  1. Does Vitest have an interactive watch mode in which I could filter tests using filenames or/and test names?
  2. If yes, does it have something akin to jest-watch-typehead?

Yes; here is an example in @statelyai/agent:

CleanShot 2024-08-07 at 07 39 00

with-heart commented 3 months ago

I'd like to block this on updating the VS Code launch.json script. It's essential to my workflow.

I've got you buddy 🤗

with-heart commented 3 months ago

I'd like to block this on updating the VS Code launch.json script. It's essential to my workflow.

@Andarist Wanna test it locally and make sure it's working the way you expect?

Andarist commented 3 months ago

I noticed it's fairly easy to lose those typeahead filters in watch mode (for example pressing Enter clears them). It's annoying but not a big deal.

When debugging with VS Code, I can't disable source mapped stepping - it still shows me a location in the source file (albeit a different/broken one). This is way more annoying, probably something I can live with but well. I just wish that console evaluation could use original references, is this too much to ask for? 😭 😭 😭 (to clarify, this is just something that current debuggers suck at cause they are not utilizing sourcemapped info to its full extent)

with-heart commented 3 months ago

I noticed it's fairly easy to lose those typeahead filters in watch mode (for example pressing Enter clears them). It's annoying but not a big deal.

Yeah for some reason they chose to use r for re-running filtered tests. Quite an annoying change if you're a long-time jest user 🥲

boneskull commented 3 months ago

Just wanted to plug Wallaby for running tests in "watch" mode (or even as you type). I've been a user for years and I haven't found anything better.