Skip to content

Own the Jest setup so the tests survive @wordpress/scripts 36 - #666

Merged
pfefferle merged 3 commits into
mainfrom
fix/jest-wp-scripts-36
Sep 28, 2026
Merged

pfefferle merged 3 commits into
mainfrom
fix/jest-wp-scripts-36

Conversation

@pfefferle

Copy link
Copy Markdown
Owner

Same fix as Automattic/wordpress-activitypub#3829.

@wordpress/scripts 36 hands test-unit-js to Vitest, so the jest job on #661 exits without running any tests. The same release also drops config/jest-unit.config.js and the bundled Jest dependencies, so switching to test-unit-jest alone is not enough.

This PR:

  • switches test:unit and test:unit:watch to test-unit-jest
  • adds jest, jest-environment-jsdom, babel-jest, @babel/core, @wordpress/jest-preset-default and @wordpress/babel-preset-default as dev dependencies
  • builds jest.config.js on @wordpress/jest-preset-default directly and configures Babel there, so it does not change the webpack build

The lockfile diff is big, but it is mostly npm deduplicating nested Jest packages now that Jest is a direct dependency.

Testing

  • npm run test:unit: 3 suites, 47 tests pass
  • With @wordpress/scripts 36 added temporarily (not saved to the manifest), npm run test:unit and npm run build pass as well

# Conflicts:
#	package-lock.json
#	package.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Update the Jest workflow’s Node version to one supported by @wordpress/scripts 36.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR makes Jest configuration project-owned so unit tests continue working with @wordpress/scripts 36.

Changes:

  • Switches unit-test scripts to test-unit-jest.
  • Adds direct Jest, Babel, and WordPress preset dependencies.
  • Adds local Jest and Babel configuration.
File Description
package.json Updates test scripts and development dependencies.
package-lock.json Locks the Jest and Babel dependency tree.
jest.config.js Configures the WordPress Jest preset and Babel transformation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread package.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The reviewed changes have no unresolved blocking issues.

Review effort: Lite
Findings: None

Resolved since last review (1)

@pfefferle
pfefferle merged commit b43fc1c into main Sep 28, 2026
2 checks passed
@pfefferle
pfefferle deleted the fix/jest-wp-scripts-36 branch September 28, 2026 08:28
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