Skip to content

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

Open
manzoorwanijk wants to merge 5 commits into
trunkfrom
update/jest-config-organize-module-map
Open

Unit Tests: Reorganise the jest config file.#80940
manzoorwanijk wants to merge 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

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>

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

Copy link
Copy Markdown

Size Change: -28 B (0%)

Total Size: 7.76 MB

📦 View Changed
Filename Size Change
build/scripts/element/index.min.js 5.17 kB -28 B (-0.54%)

compressed-size-action

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.

1 participant