close
Skip to content

Test(Integration): migrate test/integration into @wordpress/integration-tests workspace#77556

Merged
manzoorwanijk merged 7 commits into
WordPress:trunkfrom
USERSATOSHI:try/migrate-test-integration-to-workspace
Apr 28, 2026
Merged

Test(Integration): migrate test/integration into @wordpress/integration-tests workspace#77556
manzoorwanijk merged 7 commits into
WordPress:trunkfrom
USERSATOSHI:try/migrate-test-integration-to-workspace

Conversation

@USERSATOSHI
Copy link
Copy Markdown
Contributor

@USERSATOSHI USERSATOSHI commented Apr 22, 2026

What?
Part of #75041

Migrates test/integration into a proper npm workspace @wordpress/integration-tests.

Why?

The integration test suite previously had no package.json and was not a registered workspace, meaning it relied entirely on hoisted root and unit-test dependencies with no explicit ownership. This PR ensures the workspace does not rely on root dependencies once dependency isolation is enforced.

How?

  • Adds test/integration/package.json declaring the new @wordpress/integration-tests workspace with only the dependencies unique to integration tests (ajv, fast-glob, @wordpress/scripts). All other deps (e.g. jest, testing-library) are resolved via hoisting from test/unit and packages/scripts.
  • Adds test/integration/jest.config.js that extends test/unit/jest.config.js, scoping test discovery to test/integration/**.
  • Registers test/integration in the root package.json workspaces array.

Integration tests continue to run as part of npm run test:unit but can now also be run independently.

Testing Instructions

  • CI should suffice.

Note: The fixture uses integration through unit tests, and I’m not sure if this should be handled from the integration side.

If it is required, we can add the corresponding Jest configuration and scripts back.

- Add test/integration workspace with package.json and Jest config
- Add integration test scripts to root package.json
- Link @wordpress/integration-tests in package-lock.json
- Add bin/test-native-args.sh for testing native arg forwarding
Thought CI has special test unit syntax for integration but they are run with others so these are not needed now
@USERSATOSHI USERSATOSHI marked this pull request as ready for review April 22, 2026 12:01
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

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: USERSATOSHI <tusharbharti@git.wordpress.org>
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.

@Mamaduka
Copy link
Copy Markdown
Member

Mamaduka commented Apr 22, 2026

Let's ensure we don't repeat issues from #77063.

@USERSATOSHI
Copy link
Copy Markdown
Contributor Author

Let's ensure we don't repeat issues from #77063.

Right now, this workspace doesn’t expose any scripts, and the fixture runs the unit test version which invokes test/integration via args. Because of that, this issue shouldn’t occur here.

I’m waiting for input on whether we want to separate scripts for this case.

If we do switch to using test:integration directly, I’ll update it to use the -- argument forwarding approach.

@Mamaduka
Copy link
Copy Markdown
Member

Thanks for the confirmation, @USERSATOSHI!

I'll defer to @manzoorwanijk on similar PRs.

@manzoorwanijk manzoorwanijk self-requested a review April 22, 2026 12:40
@manzoorwanijk manzoorwanijk added the [Type] Code Quality Issues or PRs that relate to code quality label Apr 22, 2026
@manzoorwanijk manzoorwanijk self-assigned this Apr 22, 2026
@manzoorwanijk
Copy link
Copy Markdown
Member

From a quick look

  • Adds test/integration/jest.config.js that extends test/unit/jest.config.js, scoping test discovery to test/integration/**.
  • Adds test:integration, test:integration:watch, and test:integration:debug scripts to the root package.json.

I don't see those changes. 🤔

It seems that the workspace is imported here
https://github.com/USERSATOSHI/gutenberg/blob/a98f1335fefc9cdae460c2e4d82640e588574aa6/packages/block-library/src/cover/test/edit.js#L10-L13

Do we need to update that by adding the package as a dev dependency to block-library and then use the package import instead of path import?

Comment on lines +22 to +25
"devDependencies": {
"ajv": "^8.17.1",
"fast-glob": "^3.2.7"
},
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.

Let us ensure that we declare all the dependencies that the workspace uses.

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.

Also, agv can be removed from root package.json

"gutenberg",
"integration-tests"
],
"homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/test/integration/README.md",
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.

This file doesn't exist. Let us create one.

Copy link
Copy Markdown
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

Let us polish things a bit as mentioned above.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the integration test suite into its own npm workspace (@wordpress/integration-tests) to make its dependency ownership explicit and prepare for stricter workspace dependency isolation.

Changes:

  • Add test/integration/package.json declaring the new @wordpress/integration-tests workspace and its integration-test-only devDependencies.
  • Register test/integration in the root package.json workspaces array.
  • Update package-lock.json workspace metadata for the new package.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
test/integration/package.json Introduces a new workspace package for integration tests and declares devDependencies.
package.json Adds test/integration to the monorepo workspaces list.
package-lock.json Records the new workspace link and package metadata in the lockfile.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +21 to +22
},
"devDependencies": {
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

Other test workspaces define workspace-scoped scripts and include the runner dependency they use (e.g. @wordpress/unit-tests includes @wordpress/scripts and test:unit* scripts in test/unit/package.json:22-48, and e2e/performance do similarly). This new @wordpress/integration-tests package currently has no scripts and no @wordpress/scripts; if the intent is to run integration tests independently via npm run --workspace @wordpress/integration-tests …, add the corresponding scripts and required devDependencies to match that established pattern.

Suggested change
},
"devDependencies": {
},
"scripts": {
"test:integration": "wp-scripts test-unit-js",
"test:integration:watch": "npm run test:integration -- --watch"
},
"devDependencies": {
"@wordpress/scripts": "^30.13.0",

Copilot uses AI. Check for mistakes.
Comment thread package.json
Comment on lines 254 to 256
"test/e2e",
"test/integration",
"test/performance",
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

PR description mentions adding test:integration/watch/debug scripts and a test/integration/jest.config.js, but those changes aren’t present (root scripts still only include unit-test runners, and test/integration/ has no jest config). Either update the PR description or include the missing script/config changes so the workspace can actually be executed independently as described.

Copilot uses AI. Check for mistakes.
"gutenberg",
"integration-tests"
],
"homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/test/integration/README.md",
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

The homepage points to test/integration/README.md, but there is no README.md at test/integration/ (only READMEs deeper in fixtures). This makes the package metadata link dead; either add test/integration/README.md or update the homepage URL to the directory (without README.md).

Suggested change
"homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/test/integration/README.md",
"homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/test/integration/",

Copilot uses AI. Check for mistakes.
@USERSATOSHI
Copy link
Copy Markdown
Contributor Author

From a quick look

  • Adds test/integration/jest.config.js that extends test/unit/jest.config.js, scoping test discovery to test/integration/**.
  • Adds test:integration, test:integration:watch, and test:integration:debug scripts to the root package.json.

I don't see those changes. 🤔

Oh right, I removed them thinking we don't need them anymore. My bad, forgot to update that part.

It seems that the workspace is imported here USERSATOSHI/gutenberg@a98f133/packages/block-library/src/cover/test/edit.js#L10-L13

Do we need to update that by adding the package as a dev dependency to block-library and then use the package import instead of path import?

Sure let me check that!

Copy link
Copy Markdown
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

This is almost ready to land. Let us update this branch from trunk and address one inline comment and then we are good to go.

Comment thread test/integration/README.md Outdated
@@ -0,0 +1,58 @@
# Integration Tests

This directory contains the integration test suite for the Gutenberg project, published as the `@wordpress/integration-tests` workspace package.
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.

This is not published.

Copy link
Copy Markdown
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

This looks good now. Thank you for working on this.

@manzoorwanijk
Copy link
Copy Markdown
Member

Can we please update the branch from trunk?

@manzoorwanijk manzoorwanijk merged commit 5c15b43 into WordPress:trunk Apr 28, 2026
39 checks passed
@github-actions github-actions Bot added this to the Gutenberg 23.1 milestone Apr 28, 2026
t-hamano pushed a commit that referenced this pull request Apr 29, 2026
…ace (#77556)

* Add integration test workspace and scripts

- Add test/integration workspace with package.json and Jest config
- Add integration test scripts to root package.json
- Link @wordpress/integration-tests in package-lock.json
- Add bin/test-native-args.sh for testing native arg forwarding

* chore: remove my test script whoops

* chore: workspaces list is alphabetically ordered

* chore: remove not needed files

Thought CI has special test unit syntax for integration but they are run with others so these are not needed now

* chore: update package dependencies and add integration test documentation

* chore: clarify README about integration test suite and workspace package

Co-authored-by: USERSATOSHI <tusharbharti@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
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.

4 participants