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(dev-dock/backend): move from jest to vitest #5739

Merged
merged 3 commits into from
Dec 12, 2024

Conversation

eventualbuddha
Copy link
Collaborator

@eventualbuddha eventualbuddha commented Dec 12, 2024

...(await importActual<typeof import('@votingworks/utils')>()),
isFeatureFlagEnabled: (flag) => featureFlagMock.isEnabled(flag),
})
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's this new pattern of passing in importActual rather than just using vi.importActual? Also what are all the type annotations for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is what @kofi-q's script generated, which seemed a little nicer than having to repeat the string. The type annotation on the importActual call tells it to treat the return type as the import of that module, and the type annotation at the return position of the call to vi.mock's callback tells it to expect an object of that type. This should ensure we don't miss anything or typo an export name.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice, thanks for explaining!

This way we can replace the `jest` with `vi` at individual callsites as we get to them.
@eventualbuddha eventualbuddha force-pushed the brian/refactor/test/inline-advancetimers branch from 0d00519 to 72265b0 Compare December 12, 2024 18:26
@eventualbuddha eventualbuddha force-pushed the 5735-libsdev-dockbackend branch from ea2ec34 to 3de6d01 Compare December 12, 2024 18:27
Base automatically changed from brian/refactor/test/inline-advancetimers to vitest December 12, 2024 18:56
@eventualbuddha eventualbuddha merged commit b428d24 into vitest Dec 12, 2024
62 checks passed
@eventualbuddha eventualbuddha deleted the 5735-libsdev-dockbackend branch December 12, 2024 18:57
eventualbuddha added a commit that referenced this pull request Dec 19, 2024
* refactor(jest): inline calls to `advanceTimers`

This way we can replace the `jest` with `vi` at individual callsites as we get to them.

* test(dev-dock/backend): move from `jest` to `vitest`

* test(dev-dock/backend): remove outdated jest config
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.

2 participants