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

Upgrade @cloudflare/vitest-pool-workers to Vitest v2+ #6232

Merged
merged 9 commits into from
Sep 13, 2024

Conversation

penalosa
Copy link
Contributor

@penalosa penalosa commented Jul 9, 2024

What this PR solves / how to test

Fixes #6215

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Included
    • Tests not necessary because: The existing (extensive) Vitest tests are enough to validate that the upgrade works
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required / Maybe required
    • Not required because: e2e does not cover vitest
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Changeset included
    • Not necessary because:
  • Public documentation

Copy link

changeset-bot bot commented Jul 9, 2024

🦋 Changeset detected

Latest commit: acc0f99

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/vitest-pool-workers Minor

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Contributor

github-actions bot commented Jul 9, 2024

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10852453045/npm-package-wrangler-6232

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6232/npm-package-wrangler-6232

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10852453045/npm-package-wrangler-6232 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10852453045/npm-package-create-cloudflare-6232 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10852453045/npm-package-cloudflare-kv-asset-handler-6232
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10852453045/npm-package-miniflare-6232
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10852453045/npm-package-cloudflare-pages-shared-6232
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10852453045/npm-package-cloudflare-vitest-pool-workers-6232
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10852453045/npm-package-cloudflare-workers-editor-shared-6232
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10852453045/npm-package-cloudflare-workers-shared-6232

Note that these links will no longer work once the GitHub Actions artifact expires.


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240909.0
workerd 1.20240909.0 1.20240909.0
workerd --version 1.20240909.0 2024-09-09

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@webbertakken
Copy link
Contributor

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6232/npm-package-wrangler-6232

This ends up with an error for now

npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: @cloudflare/[email protected]
npm error Found: [email protected]
npm error node_modules/vitest
npm error   peerOptional vitest@"*" from [email protected]
npm error   node_modules/eslint-plugin-vitest
npm error     dev eslint-plugin-vitest@"^0.5.4" from the root project
npm error   peerOptional vitest@">= 0.32" from @testing-library/[email protected]
npm error   node_modules/@testing-library/jest-dom
npm error     dev @testing-library/jest-dom@"^6.4.6" from the root project
npm error   2 more (@vitest/coverage-v8, the root project)
npm error
npm error Could not resolve dependency:
npm error peer vitest@"1.3.x - 1.5.x" from @cloudflare/[email protected]
npm error node_modules/@cloudflare/vitest-pool-workers
npm error   dev @cloudflare/vitest-pool-workers@"^0.4.14" from the root project
npm error
npm error Conflicting peer dependency: [email protected]
npm error node_modules/vitest
npm error   peer vitest@"1.3.x - 1.5.x" from @cloudflare/[email protected]
npm error   node_modules/@cloudflare/vitest-pool-workers
npm error     dev @cloudflare/vitest-pool-workers@"^0.4.14" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.

@Codex-
Copy link

Codex- commented Sep 2, 2024

I'd love to test these changes but have found that trying to reference the PR release for vitest-pool-workers does not resolve 🤔

@lrapoport-cf lrapoport-cf added the caretaking Priority for caretaking label Sep 9, 2024
@danawoodman
Copy link

Do we have any ETA of when this will be ready to use?

expect(result.stdout).toMatch(
"stdout | index.test.ts:4:10\nnew describe"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to be a change in the Vitest output to remove line numbers (verified by upgrading Wrangler to Vitest v2+ and seeing the change)

Comment on lines +80 to +82
"@vitest/runner": "2.0.x",
"@vitest/snapshot": "2.0.x",
"vitest": "2.0.x"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These don't use the catalog because I'm hopeful we can make it a range in future

@penalosa penalosa marked this pull request as ready for review September 13, 2024 02:58
@penalosa penalosa requested review from a team as code owners September 13, 2024 02:58
import { unstable_dev } from "wrangler";

let output = "";
function spyOnConsoleMethod(name: keyof typeof console) {
vi.spyOn(console, name).mockImplementation((...args: unknown[]) => {
(vi.spyOn(console, name) as Mock).mockImplementation((...args: unknown[]) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

For reference this is needed because the name variable here does not result in the spyOn() function being narrowed enough for it to generate a sensible return type, resultng in never.

packages/miniflare/src/index.ts Outdated Show resolved Hide resolved
packages/vitest-pool-workers/src/pool/index.ts Outdated Show resolved Hide resolved
packages/vitest-pool-workers/test/global-setup.ts Outdated Show resolved Hide resolved
@penalosa penalosa added the skip-pr-validation Skip validation of the required PR description format label Sep 13, 2024
@penalosa penalosa merged commit f3c0400 into main Sep 13, 2024
32 of 36 checks passed
@penalosa penalosa deleted the penalosa/vitest-v2 branch September 13, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
caretaking Priority for caretaking skip-pr-validation Skip validation of the required PR description format
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

🐛 Update vitest-pool-workers to support vitest >= 2.x
6 participants