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

Run fixture tests with vitest #2496

Merged
merged 11 commits into from
Jan 5, 2023
Merged

Run fixture tests with vitest #2496

merged 11 commits into from
Jan 5, 2023

Conversation

GregBrimble
Copy link
Member

@GregBrimble GregBrimble commented Jan 4, 2023

Adopts vitest for fixture tests (except for the local-mode-tests which are a bit different).

Author has included the following, where applicable:

  • Tests
  • Changeset

Reviewer has performed the following, where applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

@changeset-bot
Copy link

changeset-bot bot commented Jan 4, 2023

⚠️ No Changeset found

Latest commit: 1886c46

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2023

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/runs/3848495686/npm-package-wrangler-2496

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/runs/3848495686/npm-package-wrangler-2496 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/runs/3848495686/npm-package-cloudflare-pages-shared-2496

@codecov
Copy link

codecov bot commented Jan 4, 2023

Codecov Report

Merging #2496 (1886c46) into main (4c0e230) will increase coverage by 0.14%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2496      +/-   ##
==========================================
+ Coverage   72.13%   72.28%   +0.14%     
==========================================
  Files         156      156              
  Lines        9720     9687      -33     
  Branches     2546     2547       +1     
==========================================
- Hits         7012     7002      -10     
+ Misses       2708     2685      -23     
Impacted Files Coverage Δ
packages/wrangler/src/logger.ts 86.04% <0.00%> (-13.96%) ⬇️
packages/wrangler/src/publish/publish.ts 85.75% <0.00%> (-0.46%) ⬇️
packages/wrangler/src/tail/index.ts 92.85% <0.00%> (-0.11%) ⬇️
packages/wrangler/src/init.ts 94.75% <0.00%> (ø)
packages/wrangler/src/delete.ts 100.00% <0.00%> (ø)
packages/wrangler/src/pages/publish.tsx 66.47% <0.00%> (ø)
packages/wrangler/src/pages/projects.tsx 81.15% <0.00%> (ø)
packages/wrangler/src/d1/migrations/apply.tsx 34.52% <0.00%> (ø)
packages/wrangler/src/pages/deployment-tails.tsx
packages/wrangler/src/index.tsx
... and 35 more

@GregBrimble GregBrimble marked this pull request as ready for review January 4, 2023 22:07
@GregBrimble GregBrimble requested a review from a team as a code owner January 4, 2023 22:07
Comment on lines +10 to +11
"test": "npx vitest",
"test:ci": "npx vitest"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a different script for CI?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just seems to be the pattern we've adopted everywhere. Didn't want to change too much all in this one PR so left as-was.

@@ -1,7 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
"types": ["node", "vitest"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, is @types/vitest even a thing? Do we need to specify "vitest" here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I think you're right. Not required. They have vitest/globals if you're using the global helpers like describe, so I think my brain just crossed wires and blindly added vitest here when it isn't needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

No I don't think it is, Vitest types should just work. Especially if you are explicitly importing in the test utilities which is one of my only requests, which is not to make everything magically global like Jest

Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

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

A LOT of it.concurrent I think we can just do it at the top level if we want the suites to run in parallel.
If you use .concurrent on a suite, every test in it will be run in parallel.

https://vitest.dev/guide/features.html#running-tests-concurrently

Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

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

With less green from the it.concurrent I can really see migration more clearly and it looks great. I love the Jest parity they did that is just enough that changes are not drastic but still beneficial!

@GregBrimble GregBrimble merged commit 4b6d428 into main Jan 5, 2023
@GregBrimble GregBrimble deleted the vitest-fixtures branch January 5, 2023 17:02
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.

4 participants