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: add explicit imports for jest functions #128

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

erikian
Copy link
Member

@erikian erikian commented Feb 23, 2025

describe, expect and other global Jest types are marked as unresolved on my IDE because we're missing "types": ["jest"].

@erikian erikian requested a review from a team as a code owner February 23, 2025 12:20
Copy link
Member

@dsanders11 dsanders11 left a comment

Choose a reason for hiding this comment

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

I believe these functions can be imported from @jest/globals which will better align with how it's done in Vitest, which this repo will be converted to after the Node 22 bump.

@erikian erikian force-pushed the test/add-jest-types branch from 0f2b690 to 3b328e6 Compare March 29, 2025 13:28
@erikian erikian changed the title test: add jest types to test dir test: add explicit imports for jest functions Mar 29, 2025
@erikian
Copy link
Member Author

erikian commented Mar 29, 2025

@dsanders11 agree with having explicit imports, though Jest throws Do not import `@jest/globals` outside of the Jest test environment when importing expect in test/util.ts because that file doesn't have any tests. As a quick workaround, I added a const declaration to that file so we can keep using the injected globals — I'm pretty sure that's not the most elegant way to solve the issue, so suggestions are welcome!

@erikian erikian requested a review from dsanders11 March 29, 2025 13:59
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