Skip to content

jest-console: Fix TypeScript types being available in published package - #71215

Closed
aduth wants to merge 4 commits into
trunkfrom
fix/jest-console-types
Closed

jest-console: Fix TypeScript types being available in published package#71215
aduth wants to merge 4 commits into
trunkfrom
fix/jest-console-types

Conversation

@aduth

@aduth aduth commented Aug 14, 2025

Copy link
Copy Markdown
Member

What?

Tries to fix the issue flagged at #70538 (comment)

In doing so, it also updates existing tests in packages/components which should be failing due to missing types for Jest matchers, shifting globally-available test types to be imported as part of the existing gutenberg-test-env typings.

Draft: I've had some intermittent issues with this locally, and I'm hoping to test this via CI to see if the issues are specific to my development environment, or actual problems with the implementation.

Why?

  • Ensure @wordpress/jest-console package registers TypeScript types for matchers
  • Avoid false negatives in tests, where existing use of toHaveWarned, etc. in packages/components should be failing due to missing types

How?

  • Updates @testing-library/jest-dom, where it appears that older versions override Jest matchers in such a way that non-existent matchers resolve to any rather than error
  • Shifts globally-available test types to be imported as part of the existing gutenberg-test-env typings
  • Moves @wordpress/jest-console typings to ensure they're imported in root entrypoint and available in built typings output

Testing Instructions

npm run build:package-types should pass.

Comment thread package.json
"@types/eslint": "8.56.9",
"@types/estree": "1.0.5",
"@types/istanbul-lib-report": "3.0.0",
"@types/jest": "30.0.0",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need to add this to the root of the monorepo?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It was a dependency we previously inherited through the older version of @testing-library/jest-dom, but is no longer a dependency of the latest version. We rely on it so that we can have typed Jest globals without importing from the @jest/globals package. This changes it from an implicit dependency to an explicit dependency.

@aduth

aduth commented Jan 8, 2026

Copy link
Copy Markdown
Member Author

Superseded by #74310

@aduth aduth closed this Jan 8, 2026
@aduth
aduth deleted the fix/jest-console-types branch January 8, 2026 19:48
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