Skip to content

Replace jest with vitest #421

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

Merged
merged 2 commits into from
Sep 26, 2024
Merged

Replace jest with vitest #421

merged 2 commits into from
Sep 26, 2024

Conversation

paul-sachs
Copy link
Collaborator

@paul-sachs paul-sachs commented Sep 26, 2024

Includes all linting changes, helper methods and config files.

This change cleans up a bunch of config and removes some warnings as well. Fixes #412

@paul-sachs paul-sachs marked this pull request as ready for review September 26, 2024 12:40
Includes all linting changes, helper methods and config files.

Signed-off-by: Paul Sachs <psachs@buf.build>
Copy link
Member

@timostamm timostamm left a comment

Choose a reason for hiding this comment

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

Jest is still hugely popular, but I think this is the right choice. Thanks for the migration! I'll merge this into the v2 branch.

// https://vitejs.dev/config/
export default defineConfig({
test: {
environment: "jsdom",
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

jest did so much stuff automatically. Eventually, we might take advantage of vitest's browser mode to actually run in the browser (like jasmine... software development is just a circle) and we can stop patching the dom, but for our purposes, this is fine.

Copy link
Member

Choose a reason for hiding this comment

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

jest-environment-jsdom provides a DOM so that tests for web apps can run on Node.js. Awesome.

Unfortunately, it also removes the text encoding API from globals, which Node.js has been supporting for many years now. The problem is so bad that it forced us to create @bufbuild/jest-environment-jsdom. It's a simple fix, but Jest has been sitting the problem out for years now, blaming jsdom.

Vitest does the same thing with environments, but it fixes the problem (see link above). Kudos to Vitest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah I understand what you meant now

@timostamm timostamm changed the title Replaced jest with vitest Replace jest with vitest Sep 26, 2024
@timostamm timostamm merged commit c983f09 into main Sep 26, 2024
8 checks passed
@timostamm timostamm deleted the psachs/vitest-again branch September 26, 2024 13:41
@paul-sachs paul-sachs mentioned this pull request Oct 10, 2024
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.

Tests for the example emit warnings
2 participants