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

test: move packages to workspace vitest #3551

Merged
merged 24 commits into from
Feb 4, 2025
Merged

test: move packages to workspace vitest #3551

merged 24 commits into from
Feb 4, 2025

Conversation

frolic
Copy link
Member

@frolic frolic commented Jan 31, 2025

Although #3526 fixes one instance of running tests from workspace root or in a package, it breaks down once we add more packages and parallelism. The source of this issue steps from the fact that the thing running Vitest (and thus starting up Anvil) is parallelized, rather than letting Vitest do the parallelizing.

To work around this, I made a with-anvil CLI wrapper that 1) starts up Anvil before starting the inner command and 2) passes the Anvil URL to the inner command via env var.

The downside is you have to remember to run with-anvil if you want to run Anvil tests from outside the context of the workspace root. But I left a nice warning to guide you to the right thing, making it easy to copy+paste and move on:

if (!process.env.PROOL_ANVIL_URL) {
console.warn(`
A test asked for the Anvil RPC URL, but was run outside of our test wrapper that manages Anvil instances.
You can either start an Anvil server at "${rpcUrl}" or prefix your command:
pnpm with-anvil ${process.env.npm_lifecycle_script || "vitest ..."}
`);
}

Snapshots got updated because newer Vitest changed their snapshot formatting (mostly reduces escaping).
closes #2409

Copy link

changeset-bot bot commented Jan 31, 2025

⚠️ No Changeset found

Latest commit: 7d2c73d

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

@frolic frolic changed the title test: move common to workspace vitest test: move workspace vitest Jan 31, 2025
@frolic frolic changed the title test: move workspace vitest test: move some packages to workspace vitest Jan 31, 2025
@frolic frolic marked this pull request as ready for review January 31, 2025 16:14
@frolic frolic requested a review from alvrs as a code owner January 31, 2025 16:14
because vitest global setup starts anvil at a specific port
@frolic frolic changed the title test: move some packages to workspace vitest test: move packages to workspace vitest Feb 1, 2025
@frolic frolic merged commit 2762cef into main Feb 4, 2025
15 checks passed
@frolic frolic deleted the holic/workspace-vitest branch February 4, 2025 10:41
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.

bump vitest to 1.x
2 participants