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(test): refactor test config, enable vitest and migrate packages to vitest #5946

Merged
merged 13 commits into from
Sep 25, 2024

Conversation

bjoerge
Copy link
Member

@bjoerge bjoerge commented Mar 11, 2024

Description

Note: This PR should probably be rebase+merged instead of squash merged since the commits makes sense on their own.

This includes several improvements to our unit test setup:

  • Moves dev aliases shared between several components (jest, vite, vitest, etc) to its own @repo/dev-aliases-package to make it a first class dependency (it's been a well-kept secret, tucked away in ./packages until now).
  • Introduces a @repo/test-config internal pacakge that contains the test configuration for jest (and now also vitest) so it can be a proper (dev) dependency of packages that needs it. This makes it easier to maintain test configs, and also makes it easier to remove reliance on jest in the future.
  • Splits up ci workflows, one that runs jest and one that runs vitest.
  • Migrates a few "simple" (in terms of test config complextity) packages to vitest, these should provide a good example of what it takes to migrate other packages as well:
    • @sanity/migrate
    • @sanity/block
    • @sanity/mutator
    • @sanity/schema
    • @sanity/types
    • @sanity/util

In addition I've done some minor cleanups and smaller factors, hopefully leaving the code in a better shape.

What to review

The commits here can be reviewed one-by-one.

Testing

I've made sure the following is still true:

  • The pacakges converted to vitest runs the same number as tests as they used to with jest
  • You can still run tests without first havign to build (e.g. make a fresh clone of the repo, install dependencies and then run pnpm test)
  • You can still run test studio packages without first havign to build (e.g. make a fresh clone of the repo, install dependencies and then run pnpm dev)

Beyond that, this PR should not require any additional tests.

Notes for release

n/a - internal

Copy link

vercel bot commented Mar 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 9:51am
performance-studio ✅ Ready (Inspect) Visit Preview Sep 25, 2024 9:51am
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 9:51am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 9:51am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 9:51am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Sep 25, 2024 9:51am

Copy link

socket-security bot commented Mar 11, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/vitest@2.1.1 Transitive: environment, filesystem, shell, unsafe +58 8.35 MB antfu, oreanno, patak, ...1 more

View full report↗︎

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Mar 11, 2024

Component Testing Report Updated Sep 25, 2024 9:55 AM (UTC)

✅ All Tests Passed -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 43s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 8s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 31s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 36s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 18s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 3m 0s 0 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 45s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 40s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 14s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 8s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 25s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 18s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 35s 12 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

@bjoerge bjoerge requested review from binoy14, stipsan and ricokahler and removed request for a team September 23, 2024 09:35
binoy14
binoy14 previously approved these changes Sep 23, 2024
stipsan
stipsan previously approved these changes Sep 23, 2024
Copy link
Member

@stipsan stipsan left a comment

Choose a reason for hiding this comment

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

Excellent 💖

@bjoerge bjoerge merged commit 38eca25 into next Sep 25, 2024
50 checks passed
@bjoerge bjoerge deleted the vitest branch September 25, 2024 10:01
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.

3 participants