Skip to content

Unit Tests: Reorganise the jest config file. - #80940

Merged
manzoorwanijk merged 5 commits into
trunkfrom
update/jest-config-organize-module-map
Jul 31, 2026
Merged

Unit Tests: Reorganise the jest config file.#80940
manzoorwanijk merged 5 commits into
trunkfrom
update/jest-config-organize-module-map

Conversation

@manzoorwanijk

@manzoorwanijk manzoorwanijk commented Jul 30, 2026

Copy link
Copy Markdown
Member

What?

Follow-up to #80765 (comment)

Some changes extracted from the isolated mode PR #75814

This PR updates the unit-test Jest configuration so module resolution works with isolated dependency installs as well as the default install layout. It also reorganizes moduleNameMapper and makes the list of dependencies transformed by Jest easier to maintain.

Why?

The Ariakit mappings added in #80765 point directly to the root node_modules directory. Workspace-only dependencies are not available there when dependencies are installed in isolation, so Jest cannot resolve those modules.

Some other parts of the configuration also rely on hoisted dependencies or mapper ordering. Specific mappings need to be evaluated before generic @wordpress/* mappings, and deep package imports need their own mapping.

How?

  • Resolve @ariakit/test from the Components workspace and resolve @ariakit/utils from the installed Ariakit test package.
  • Put specific module mappings before the generic WordPress package mappings.
  • Add a mapping for deep imports from transpiled WordPress packages.
  • Reuse the already computed absolute ROOT_DIR as Jest's rootDir.
  • Resolve jest-environment-jsdom explicitly.
  • Extract the dependencies that Jest must transform into a dependenciesToTransform array.

Testing Instructions

  • npm run test:unit should be happy, already checked by CI

Testing Instructions for Keyboard

Not applicable. This PR does not change the user interface.

Screenshots or screencast

Not applicable.

Use of AI Tools

OpenAI Codex, used only to draft this PR description.

@manzoorwanijk manzoorwanijk self-assigned this Jul 30, 2026
@manzoorwanijk manzoorwanijk added the [Type] Code Quality Issues or PRs that relate to code quality label Jul 30, 2026
@manzoorwanijk
manzoorwanijk marked this pull request as ready for review July 30, 2026 10:12
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@manzoorwanijk manzoorwanijk changed the title Unit test: Reorganise the jest config file. Unit Tests: Reorganise the jest config file. Jul 30, 2026
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.76 MB

compressed-size-action

@manzoorwanijk
manzoorwanijk force-pushed the update/jest-config-organize-module-map branch from 98c421c to 9fca827 Compare July 31, 2026 10:08
@manzoorwanijk
manzoorwanijk force-pushed the update/jest-config-organize-module-map branch from 9fca827 to cf04a3a Compare July 31, 2026 12:52

@Mamaduka Mamaduka left a comment

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.

Nice refactoring 🎉

@manzoorwanijk
manzoorwanijk enabled auto-merge (squash) July 31, 2026 13:18
@manzoorwanijk
manzoorwanijk merged commit a5f9334 into trunk Jul 31, 2026
43 checks passed
@manzoorwanijk
manzoorwanijk deleted the update/jest-config-organize-module-map branch July 31, 2026 13:27
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Jul 31, 2026
@github-actions

Copy link
Copy Markdown

Flaky tests detected in cf04a3a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/30632253120
📝 Reported issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants