From 30f26225a6174e26e672551a0f67390a64d5e771 Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Mon, 6 Apr 2026 16:47:40 +0530 Subject: [PATCH 01/10] refactor: migrate tests/unit to npm workspace --- .github/workflows/unit-test.yml | 4 +-- package-lock.json | 46 +++++++++++++++++++-------------- package.json | 17 +++++------- test/unit/package.json | 46 +++++++++++++++++++++++++++++++++ test/unit/tsconfig.json | 14 ++++++++++ tsconfig.json | 3 ++- 6 files changed, 97 insertions(+), 33 deletions(-) create mode 100644 test/unit/package.json create mode 100644 test/unit/tsconfig.json diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 2a745a35973cb2..1e2bb1da69ba31 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -70,7 +70,7 @@ jobs: MAXWORKERS: ${{ steps.cpu-cores.outputs.count }} SHARD: ${{ matrix.shard }} run: | - npm run test:unit -- \ + npm run --workspace @wordpress/unit-tests test:unit -- \ --ci \ --maxWorkers="$MAXWORKERS" \ --shard="$SHARD" \ @@ -119,7 +119,7 @@ jobs: - name: Run the date tests env: MAXWORKERS: ${{ steps.cpu-cores.outputs.count }} - run: npm run test:unit:date -- --ci --maxWorkers="$MAXWORKERS" --cacheDirectory="$HOME/.jest-cache" + run: npm run --workspace @wordpress/unit-tests test:unit -- --ci --maxWorkers="$MAXWORKERS" --cacheDirectory="$HOME/.jest-cache" --testPathPattern="test/unit/date" compute-previous-wordpress-version: name: Compute previous WordPress version diff --git a/package-lock.json b/package-lock.json index 6abf5294575859..538d240a8468b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,22 +15,20 @@ "storybook", "test/e2e", "test/performance", - "test/storybook-playwright" + "test/storybook-playwright", + "test/unit" ], "devDependencies": { "@apidevtools/json-schema-ref-parser": "11.6.4", "@babel/core": "7.25.7", "@emotion/babel-plugin": "11.13.5", "@emotion/is-prop-valid": "1.4.0", - "@emotion/jest": "11.14.2", "@emotion/native": "11.11.0", "@emotion/react": "11.14.0", "@emotion/styled": "11.14.1", "@inquirer/prompts": "7.2.0", "@octokit/rest": "16.26.0", "@testing-library/jest-dom": "6.9.1", - "@testing-library/react": "16.3.2", - "@testing-library/user-event": "14.6.1", "@types/node": "^20.17.10", "@types/prettier": "2.4.4", "@types/react": "^18.3.27", @@ -68,8 +66,6 @@ "husky": "7.0.0", "jest": "29.6.2", "jest-environment-jsdom": "^30.2.0", - "jest-jasmine2": "29.6.2", - "jest-junit": "13.0.0", "jest-message-util": "^29.6.2", "jest-watch-typeahead": "2.2.2", "json2md": "2.0.1", @@ -87,7 +83,6 @@ "react-dom": "18.3.1", "react-scanner": "1.2.0", "reassure": "0.7.1", - "resize-observer-polyfill": "1.5.1", "rimraf": "5.0.10", "sass": "^1.54.0", "sass-embedded": "^1.97.2", @@ -21018,6 +21013,10 @@ "resolved": "packages/undo-manager", "link": true }, + "node_modules/@wordpress/unit-tests": { + "resolved": "test/unit", + "link": true + }, "node_modules/@wordpress/upload-media": { "resolved": "packages/upload-media", "link": true @@ -63060,10 +63059,6 @@ "@wordpress/i18n": "file:../../packages/i18n" } }, - "routes/home/node_modules/@wordpress/i18n": { - "resolved": "packages/i18n", - "link": true - }, "routes/navigation": { "name": "@wordpress/navigation-route", "version": "1.0.0", @@ -63155,14 +63150,6 @@ "@wordpress/route": "file:../../packages/route" } }, - "routes/post-edit/node_modules/@wordpress/html-entities": { - "resolved": "packages/html-entities", - "link": true - }, - "routes/post-edit/node_modules/@wordpress/i18n": { - "resolved": "packages/i18n", - "link": true - }, "routes/post-list": { "name": "@wordpress/post-list", "version": "1.0.0", @@ -63379,6 +63366,27 @@ "@wordpress/storybook": "file:../../storybook", "storybook": "^10.1.11" } + }, + "test/unit": { + "name": "@wordpress/unit-tests", + "version": "0.0.0", + "license": "GPL-2.0-or-later", + "devDependencies": { + "@emotion/jest": "11.14.2", + "@testing-library/jest-dom": "6.9.1", + "@testing-library/react": "16.3.2", + "@testing-library/user-event": "14.6.1", + "@wordpress/scripts": "file:../../packages/scripts", + "babel-jest": "29.7.0", + "jest": "29.6.2", + "jest-environment-jsdom": "^30.2.0", + "jest-jasmine2": "29.6.2", + "jest-junit": "13.0.0", + "jest-message-util": "^29.6.2", + "jest-watch-typeahead": "2.2.2", + "resize-observer-polyfill": "1.5.1", + "snapshot-diff": "0.10.0" + } } } } diff --git a/package.json b/package.json index 050015d815fe8e..9586fc5e44cbb9 100644 --- a/package.json +++ b/package.json @@ -44,15 +44,12 @@ "@babel/core": "7.25.7", "@emotion/babel-plugin": "11.13.5", "@emotion/is-prop-valid": "1.4.0", - "@emotion/jest": "11.14.2", "@emotion/native": "11.11.0", "@emotion/react": "11.14.0", "@emotion/styled": "11.14.1", "@inquirer/prompts": "7.2.0", "@octokit/rest": "16.26.0", "@testing-library/jest-dom": "6.9.1", - "@testing-library/react": "16.3.2", - "@testing-library/user-event": "14.6.1", "@types/node": "^20.17.10", "@types/prettier": "2.4.4", "@types/react": "^18.3.27", @@ -90,8 +87,6 @@ "husky": "7.0.0", "jest": "29.6.2", "jest-environment-jsdom": "^30.2.0", - "jest-jasmine2": "29.6.2", - "jest-junit": "13.0.0", "jest-message-util": "^29.6.2", "jest-watch-typeahead": "2.2.2", "json2md": "2.0.1", @@ -109,7 +104,6 @@ "react-dom": "18.3.1", "react-scanner": "1.2.0", "reassure": "0.7.1", - "resize-observer-polyfill": "1.5.1", "rimraf": "5.0.10", "sass": "^1.54.0", "sass-embedded": "^1.97.2", @@ -196,9 +190,9 @@ "test:performance:debug": "npm run --workspace @wordpress/performance-tests test:performance:debug", "test:php": "npm-run-all lint:php test:unit:php", "test:php:watch": "wp-env --config .wp-env.test.json run --env-cwd='wp-content/plugins/gutenberg' cli composer run-script test:watch", - "test:unit": "wp-scripts test-unit-js --config test/unit/jest.config.js", + "test:unit": "npm run --workspace @wordpress/unit-tests test:unit", "test:unit:date": "bash ./bin/unit-test-date.sh", - "test:unit:debug": "wp-scripts --inspect-brk test-unit-js --runInBand --no-cache --verbose --config test/unit/jest.config.js ", + "test:unit:debug": "npm run --workspace @wordpress/unit-tests test:unit:debug", "test:unit:profile": "wp-scripts --cpu-prof test-unit-js --runInBand --no-cache --verbose --config test/unit/jest.config.js ", "test:unit:php:setup": "wp-env --config .wp-env.test.json start", "test:unit:php:setup:debug": "wp-env --config .wp-env.test.json start --xdebug", @@ -208,8 +202,8 @@ "test:unit:php:multisite:base": "wp-env --config .wp-env.test.json run --env-cwd='wp-content/plugins/gutenberg' wordpress vendor/bin/phpunit -c phpunit/multisite.xml --verbose", "test:unit:php:multisite": "npm-run-all test:unit:php:setup test:unit:php:multisite:base", "test:unit:php:multisite:debug": "npm-run-all test:unit:php:setup:debug test:unit:php:multisite:base", - "test:unit:update": "npm run test:unit -- --updateSnapshot", - "test:unit:watch": "npm run test:unit -- --watch", + "test:unit:update": "npm run --workspace @wordpress/unit-tests test:unit -- --updateSnapshot", + "test:unit:watch": "npm run --workspace @wordpress/unit-tests test:unit:watch", "wp-env": "wp-env", "wp-env-test": "wp-env --config .wp-env.test.json" }, @@ -252,6 +246,7 @@ "storybook", "test/e2e", "test/performance", - "test/storybook-playwright" + "test/storybook-playwright", + "test/unit" ] } diff --git a/test/unit/package.json b/test/unit/package.json new file mode 100644 index 00000000000000..e50993f40a052c --- /dev/null +++ b/test/unit/package.json @@ -0,0 +1,46 @@ +{ + "name": "@wordpress/unit-tests", + "version": "0.0.0", + "description": "Unit tests for WordPress Gutenberg.", + "private": true, + "author": "The WordPress Contributors", + "license": "GPL-2.0-or-later", + "keywords": [ + "wordpress", + "gutenberg", + "unit-tests" + ], + "homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/test/unit/README.md", + "repository": { + "type": "git", + "url": "git+https://github.com/WordPress/gutenberg.git", + "directory": "test/unit" + }, + "bugs": { + "url": "https://github.com/WordPress/gutenberg/issues" + }, + "devDependencies": { + "@emotion/jest": "11.14.2", + "@testing-library/jest-dom": "6.9.1", + "@testing-library/react": "16.3.2", + "@testing-library/user-event": "14.6.1", + "@wordpress/scripts": "file:../../packages/scripts", + "babel-jest": "29.7.0", + "jest": "29.6.2", + "jest-environment-jsdom": "^30.2.0", + "jest-jasmine2": "29.6.2", + "jest-junit": "13.0.0", + "jest-message-util": "^29.6.2", + "jest-watch-typeahead": "2.2.2", + "resize-observer-polyfill": "1.5.1", + "snapshot-diff": "0.10.0" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test:unit": "wp-scripts test-unit-js --config jest.config.js", + "test:unit:watch": "npm run test:unit -- --watch", + "test:unit:debug": "wp-scripts --inspect-brk test-unit-js --runInBand --no-cache --verbose --config jest.config.js" + } +} diff --git a/test/unit/tsconfig.json b/test/unit/tsconfig.json new file mode 100644 index 00000000000000..dbe1f27b8f4a00 --- /dev/null +++ b/test/unit/tsconfig.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig.json", + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "checkJs": false, + "forceConsistentCasingInFileNames": true, + "module": "CommonJS", + "noEmit": true, + "rootDir": ".", + "types": [ "node" ] + }, + "include": [ "." ], + "exclude": [] +} diff --git a/tsconfig.json b/tsconfig.json index 9f4dce3ff440af..77bdfb38d1f5d7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -84,7 +84,8 @@ { "path": "storybook" }, { "path": "test/e2e" }, { "path": "test/storybook-playwright" }, - { "path": "test/performance" } + { "path": "test/performance" }, + { "path": "test/unit" } ], "files": [] } From 6038804315288debb4ad6ddf79d6cb6b6364248a Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Mon, 6 Apr 2026 16:48:25 +0530 Subject: [PATCH 02/10] chore: fixing jest config due to new relative path --- test/unit/jest.config.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/unit/jest.config.js b/test/unit/jest.config.js index da23dc791722ee..df877d277e28b3 100644 --- a/test/unit/jest.config.js +++ b/test/unit/jest.config.js @@ -1,12 +1,25 @@ /** * External dependencies */ +const path = require( 'path' ); const glob = require( 'glob' ).sync; +/** + * Path to root project directory. + */ +const ROOT_DIR = path.resolve( __dirname, '../..' ); + +// Ensure Babel config resolution works from the repo root, +// even when Jest runs from the workspace directory. +process.chdir( ROOT_DIR ); + // Finds all packages which are transpiled with Babel to force Jest to use their source code. -const transpiledPackageNames = glob( 'packages/*/src/index.{js,ts,tsx}' ).map( - ( fileName ) => fileName.split( '/' )[ 1 ] -); +const transpiledPackageNames = glob( + path.join( ROOT_DIR, 'packages/*/src/index.{js,ts,tsx}' ) +).map( ( fileName ) => { + const relative = path.relative( ROOT_DIR, fileName ); + return relative.split( path.sep )[ 1 ]; +} ); // Make sure the tests run in UTC timezone, regardless of the system timezone. process.env.TZ = 'UTC'; From 6c96249facdb44490cddfde48bcee1792c7ec42d Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Thu, 9 Apr 2026 13:04:55 +0530 Subject: [PATCH 03/10] Fix IS_GUTENBERG_PLUGIN detection in unit tests Read IS_GUTENBERG_PLUGIN directly from root package.json instead of relying on npm_package_config_* env vars, which are unreliable in npm workspaces. Set globals early in Jest config to ensure correct module-level guards. --- .github/workflows/unit-test.yml | 2 +- test/unit/config/gutenberg-env.js | 10 ++++++++-- test/unit/jest.config.js | 11 +++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 1e2bb1da69ba31..6bda490df835ad 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -70,7 +70,7 @@ jobs: MAXWORKERS: ${{ steps.cpu-cores.outputs.count }} SHARD: ${{ matrix.shard }} run: | - npm run --workspace @wordpress/unit-tests test:unit -- \ + npm run test:unit -- \ --ci \ --maxWorkers="$MAXWORKERS" \ --shard="$SHARD" \ diff --git a/test/unit/config/gutenberg-env.js b/test/unit/config/gutenberg-env.js index f6ea2d16c1c79d..be52205fac917d 100644 --- a/test/unit/config/gutenberg-env.js +++ b/test/unit/config/gutenberg-env.js @@ -7,7 +7,13 @@ // eslint-disable-next-line @wordpress/wp-global-usage globalThis.IS_WORDPRESS_CORE = true; -// Inject the `IS_GUTENBERG_PLUGIN` global, used for feature flagging. +// Inject IS_GUTENBERG_PLUGIN — read from root package.json directly since +// npm_package_config_* isn't reliable when running via npm workspaces. +const path = require( 'path' ); +const rootPackageJson = require( + path.resolve( __dirname, '../../../package.json' ) +); + // eslint-disable-next-line @wordpress/wp-global-usage globalThis.IS_GUTENBERG_PLUGIN = - String( process.env.npm_package_config_IS_GUTENBERG_PLUGIN ) === 'true'; + rootPackageJson?.config?.IS_GUTENBERG_PLUGIN === true; diff --git a/test/unit/jest.config.js b/test/unit/jest.config.js index df877d277e28b3..e0bd4a65ec4c1c 100644 --- a/test/unit/jest.config.js +++ b/test/unit/jest.config.js @@ -9,6 +9,12 @@ const glob = require( 'glob' ).sync; */ const ROOT_DIR = path.resolve( __dirname, '../..' ); +// Read directly from root package.json — npm_package_config_* isn't reliable +// in workspace context, and setupFiles run too late for module-level guards. +const rootPackageJson = require( path.join( ROOT_DIR, 'package.json' ) ); +const IS_GUTENBERG_PLUGIN = + rootPackageJson?.config?.IS_GUTENBERG_PLUGIN === true; + // Ensure Babel config resolution works from the repo root, // even when Jest runs from the workspace directory. process.chdir( ROOT_DIR ); @@ -26,6 +32,11 @@ process.env.TZ = 'UTC'; module.exports = { rootDir: '../../', + globals: { + // Set before any module loads so module-level guards evaluate correctly. + IS_GUTENBERG_PLUGIN, + IS_WORDPRESS_CORE: true, + }, moduleNameMapper: { // Mock @wordpress/vips/worker before the general pattern so it doesn't try to load the real file. // The worker-code.ts file is auto-generated during full builds and is gitignored. From d60bf8d7c479fd3e5d72e4c7bbe64dca15a0001f Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Mon, 13 Apr 2026 14:13:53 +0530 Subject: [PATCH 04/10] chore: update tsconfig to make missing files work and revert gutenverg env changes. --- test/unit/config/gutenberg-env.js | 8 +------- test/unit/tsconfig.json | 8 +++++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/unit/config/gutenberg-env.js b/test/unit/config/gutenberg-env.js index be52205fac917d..0cee3262cd2da9 100644 --- a/test/unit/config/gutenberg-env.js +++ b/test/unit/config/gutenberg-env.js @@ -8,12 +8,6 @@ globalThis.IS_WORDPRESS_CORE = true; // Inject IS_GUTENBERG_PLUGIN — read from root package.json directly since -// npm_package_config_* isn't reliable when running via npm workspaces. -const path = require( 'path' ); -const rootPackageJson = require( - path.resolve( __dirname, '../../../package.json' ) -); - // eslint-disable-next-line @wordpress/wp-global-usage globalThis.IS_GUTENBERG_PLUGIN = - rootPackageJson?.config?.IS_GUTENBERG_PLUGIN === true; + String( process.env.npm_package_config_IS_GUTENBERG_PLUGIN ) === 'true'; diff --git a/test/unit/tsconfig.json b/test/unit/tsconfig.json index dbe1f27b8f4a00..5f99c901315537 100644 --- a/test/unit/tsconfig.json +++ b/test/unit/tsconfig.json @@ -6,7 +6,13 @@ "forceConsistentCasingInFileNames": true, "module": "CommonJS", "noEmit": true, - "rootDir": ".", + // the following 5 lines are needed else the missing file errors shows up on build. If there is a better solution, update this config. + "composite": false, + "declaration": false, + "declarationMap": false, + "declarationDir": null, + "emitDeclarationOnly": false, + "rootDir": "../..", "types": [ "node" ] }, "include": [ "." ], From 6ca095547798dc4c6513f063da99d4f3ba6241fc Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Mon, 13 Apr 2026 16:01:03 +0530 Subject: [PATCH 05/10] chore: removing changes that are not needed --- .github/workflows/unit-test.yml | 2 +- test/unit/config/gutenberg-env.js | 2 +- test/unit/jest.config.js | 11 ----------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 6bda490df835ad..2a745a35973cb2 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -119,7 +119,7 @@ jobs: - name: Run the date tests env: MAXWORKERS: ${{ steps.cpu-cores.outputs.count }} - run: npm run --workspace @wordpress/unit-tests test:unit -- --ci --maxWorkers="$MAXWORKERS" --cacheDirectory="$HOME/.jest-cache" --testPathPattern="test/unit/date" + run: npm run test:unit:date -- --ci --maxWorkers="$MAXWORKERS" --cacheDirectory="$HOME/.jest-cache" compute-previous-wordpress-version: name: Compute previous WordPress version diff --git a/test/unit/config/gutenberg-env.js b/test/unit/config/gutenberg-env.js index 0cee3262cd2da9..f6ea2d16c1c79d 100644 --- a/test/unit/config/gutenberg-env.js +++ b/test/unit/config/gutenberg-env.js @@ -7,7 +7,7 @@ // eslint-disable-next-line @wordpress/wp-global-usage globalThis.IS_WORDPRESS_CORE = true; -// Inject IS_GUTENBERG_PLUGIN — read from root package.json directly since +// Inject the `IS_GUTENBERG_PLUGIN` global, used for feature flagging. // eslint-disable-next-line @wordpress/wp-global-usage globalThis.IS_GUTENBERG_PLUGIN = String( process.env.npm_package_config_IS_GUTENBERG_PLUGIN ) === 'true'; diff --git a/test/unit/jest.config.js b/test/unit/jest.config.js index e0bd4a65ec4c1c..df877d277e28b3 100644 --- a/test/unit/jest.config.js +++ b/test/unit/jest.config.js @@ -9,12 +9,6 @@ const glob = require( 'glob' ).sync; */ const ROOT_DIR = path.resolve( __dirname, '../..' ); -// Read directly from root package.json — npm_package_config_* isn't reliable -// in workspace context, and setupFiles run too late for module-level guards. -const rootPackageJson = require( path.join( ROOT_DIR, 'package.json' ) ); -const IS_GUTENBERG_PLUGIN = - rootPackageJson?.config?.IS_GUTENBERG_PLUGIN === true; - // Ensure Babel config resolution works from the repo root, // even when Jest runs from the workspace directory. process.chdir( ROOT_DIR ); @@ -32,11 +26,6 @@ process.env.TZ = 'UTC'; module.exports = { rootDir: '../../', - globals: { - // Set before any module loads so module-level guards evaluate correctly. - IS_GUTENBERG_PLUGIN, - IS_WORDPRESS_CORE: true, - }, moduleNameMapper: { // Mock @wordpress/vips/worker before the general pattern so it doesn't try to load the real file. // The worker-code.ts file is auto-generated during full builds and is gitignored. From e80dc8bb48dcf30e167e102680b3f55f19596abc Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Mon, 13 Apr 2026 19:14:44 +0530 Subject: [PATCH 06/10] chore: update dependencies and improve test scripts; remove unused tsconfig --- package.json | 9 ++++----- test/unit/package.json | 23 ++++++++++++----------- test/unit/tsconfig.json | 20 -------------------- 3 files changed, 16 insertions(+), 36 deletions(-) delete mode 100644 test/unit/tsconfig.json diff --git a/package.json b/package.json index 33648aa49b8da2..087d03bdffba43 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "@babel/core": "7.25.7", "@emotion/babel-plugin": "11.13.5", "@emotion/is-prop-valid": "1.4.0", + "@emotion/jest": "^11.14.2", "@emotion/native": "11.11.0", "@emotion/react": "11.14.0", "@emotion/styled": "11.14.1", @@ -91,8 +92,7 @@ "globals": "14.0.0", "husky": "7.0.0", "jest": "29.6.2", - "jest-environment-jsdom": "^30.2.0", - "jest-message-util": "^29.6.2", + "jest-junit": "^13.0.0", "jest-watch-typeahead": "2.2.2", "jsonc-parser": "3.3.1", "lerna": "8.1.9", @@ -114,7 +114,6 @@ "sass-loader": "16.0.3", "semver": "7.5.4", "simple-git": "3.24.0", - "snapshot-diff": "0.10.0", "sprintf-js": "1.1.1", "style-loader": "3.2.1", "stylelint-plugin-logical-css": "^1.2.3", @@ -144,7 +143,7 @@ "docs:theme-ref": "npm run --workspace tools/api-docs docs:theme-ref", "env": "wp-env", "fixtures:clean": "rimraf --glob \"test/integration/fixtures/blocks/*.{json,serialized.html}\"", - "fixtures:generate": "cross-env GENERATE_MISSING_FIXTURES=y npm run test:unit test/integration/full-content/ && npm run format test/integration/fixtures/blocks/*.json", + "fixtures:generate": "cross-env GENERATE_MISSING_FIXTURES=y npm run test:unit -- -- test/integration/full-content/ && npm run format test/integration/fixtures/blocks/*.json", "fixtures:regenerate": "npm-run-all fixtures:clean fixtures:generate", "format": "wp-scripts format", "preformat:php": "npm run other:update-packages:php", @@ -200,7 +199,7 @@ "test:unit": "npm run --workspace @wordpress/unit-tests test:unit", "test:unit:date": "bash ./bin/unit-test-date.sh", "test:unit:debug": "npm run --workspace @wordpress/unit-tests test:unit:debug", - "test:unit:profile": "wp-scripts --cpu-prof test-unit-js --runInBand --no-cache --verbose --config test/unit/jest.config.js ", + "test:unit:profile": "npm run --workspace @wordpress/unit-tests test:unit:profile", "test:unit:php:setup": "wp-env --config .wp-env.test.json start", "test:unit:php:setup:debug": "wp-env --config .wp-env.test.json start --xdebug", "test:unit:php:base": "wp-env --config .wp-env.test.json run --env-cwd='wp-content/plugins/gutenberg' wordpress vendor/bin/phpunit -c phpunit.xml.dist --verbose", diff --git a/test/unit/package.json b/test/unit/package.json index e50993f40a052c..ca8ad53d90f718 100644 --- a/test/unit/package.json +++ b/test/unit/package.json @@ -20,26 +20,27 @@ "url": "https://github.com/WordPress/gutenberg/issues" }, "devDependencies": { - "@emotion/jest": "11.14.2", - "@testing-library/jest-dom": "6.9.1", - "@testing-library/react": "16.3.2", - "@testing-library/user-event": "14.6.1", + "@emotion/jest": "^11.14.2", + "@testing-library/jest-dom": "^6.9.1", + "@testing-library/react": "^16.3.2", + "@testing-library/user-event": "^14.6.1", "@wordpress/scripts": "file:../../packages/scripts", - "babel-jest": "29.7.0", - "jest": "29.6.2", + "babel-jest": "^29.7.0", + "jest": "^29.6.2", "jest-environment-jsdom": "^30.2.0", - "jest-jasmine2": "29.6.2", - "jest-junit": "13.0.0", + "jest-jasmine2": "^29.6.2", + "jest-junit": "^13.0.0", "jest-message-util": "^29.6.2", - "jest-watch-typeahead": "2.2.2", - "resize-observer-polyfill": "1.5.1", - "snapshot-diff": "0.10.0" + "jest-watch-typeahead": "^2.2.2", + "resize-observer-polyfill": "^1.5.1", + "snapshot-diff": "^0.10.0" }, "publishConfig": { "access": "public" }, "scripts": { "test:unit": "wp-scripts test-unit-js --config jest.config.js", + "test:unit:profile": "wp-scripts --cpu-prof test-unit-js --runInBand --no-cache --verbose --config jest.config.js", "test:unit:watch": "npm run test:unit -- --watch", "test:unit:debug": "wp-scripts --inspect-brk test-unit-js --runInBand --no-cache --verbose --config jest.config.js" } diff --git a/test/unit/tsconfig.json b/test/unit/tsconfig.json deleted file mode 100644 index 5f99c901315537..00000000000000 --- a/test/unit/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/tsconfig.json", - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "checkJs": false, - "forceConsistentCasingInFileNames": true, - "module": "CommonJS", - "noEmit": true, - // the following 5 lines are needed else the missing file errors shows up on build. If there is a better solution, update this config. - "composite": false, - "declaration": false, - "declarationMap": false, - "declarationDir": null, - "emitDeclarationOnly": false, - "rootDir": "../..", - "types": [ "node" ] - }, - "include": [ "." ], - "exclude": [] -} From 76eb81d852b50ded1d873ea3260f932273691a54 Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Mon, 13 Apr 2026 19:27:13 +0530 Subject: [PATCH 07/10] chore: remove test/unit from tsconfig --- tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index f8b67cce4c1a4c..dc9d5c7478bdd3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -86,8 +86,7 @@ { "path": "storybook" }, { "path": "test/e2e" }, { "path": "test/storybook-playwright" }, - { "path": "test/performance" }, - { "path": "test/unit" } + { "path": "test/performance" } ], "files": [] } From 06b9d6ae8f001d9340c9d88e750dc678e30e73db Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Mon, 13 Apr 2026 19:46:36 +0530 Subject: [PATCH 08/10] chore: update deps --- package-lock.json | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 507fc99d2828bd..d641c132f486e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "@babel/core": "7.25.7", "@emotion/babel-plugin": "11.13.5", "@emotion/is-prop-valid": "1.4.0", + "@emotion/jest": "^11.14.2", "@emotion/native": "11.11.0", "@emotion/react": "11.14.0", "@emotion/styled": "11.14.1", @@ -71,8 +72,7 @@ "globals": "14.0.0", "husky": "7.0.0", "jest": "29.6.2", - "jest-environment-jsdom": "^30.2.0", - "jest-message-util": "^29.6.2", + "jest-junit": "^13.0.0", "jest-watch-typeahead": "2.2.2", "jsonc-parser": "3.3.1", "lerna": "8.1.9", @@ -94,7 +94,6 @@ "sass-loader": "16.0.3", "semver": "7.5.4", "simple-git": "3.24.0", - "snapshot-diff": "0.10.0", "sprintf-js": "1.1.1", "style-loader": "3.2.1", "stylelint-plugin-logical-css": "^1.2.3", @@ -63568,20 +63567,20 @@ "version": "0.0.0", "license": "GPL-2.0-or-later", "devDependencies": { - "@emotion/jest": "11.14.2", - "@testing-library/jest-dom": "6.9.1", - "@testing-library/react": "16.3.2", - "@testing-library/user-event": "14.6.1", + "@emotion/jest": "^11.14.2", + "@testing-library/jest-dom": "^6.9.1", + "@testing-library/react": "^16.3.2", + "@testing-library/user-event": "^14.6.1", "@wordpress/scripts": "file:../../packages/scripts", - "babel-jest": "29.7.0", - "jest": "29.6.2", + "babel-jest": "^29.7.0", + "jest": "^29.6.2", "jest-environment-jsdom": "^30.2.0", - "jest-jasmine2": "29.6.2", - "jest-junit": "13.0.0", + "jest-jasmine2": "^29.6.2", + "jest-junit": "^13.0.0", "jest-message-util": "^29.6.2", - "jest-watch-typeahead": "2.2.2", - "resize-observer-polyfill": "1.5.1", - "snapshot-diff": "0.10.0" + "jest-watch-typeahead": "^2.2.2", + "resize-observer-polyfill": "^1.5.1", + "snapshot-diff": "^0.10.0" } }, "tools/api-docs": { From 1afb0433bb62893bb325162a4c3fa0d6c4560544 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Tue, 21 Apr 2026 09:55:25 +0530 Subject: [PATCH 09/10] Explicitly declare the dependencies --- package-lock.json | 2 ++ test/unit/package.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/package-lock.json b/package-lock.json index d641c132f486e4..ee5499d7f6907a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63571,8 +63571,10 @@ "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^16.3.2", "@testing-library/user-event": "^14.6.1", + "@wordpress/jest-preset-default": "file:../../packages/jest-preset-default", "@wordpress/scripts": "file:../../packages/scripts", "babel-jest": "^29.7.0", + "glob": "^7.1.2", "jest": "^29.6.2", "jest-environment-jsdom": "^30.2.0", "jest-jasmine2": "^29.6.2", diff --git a/test/unit/package.json b/test/unit/package.json index ca8ad53d90f718..d5572ec9f9b0cd 100644 --- a/test/unit/package.json +++ b/test/unit/package.json @@ -24,8 +24,10 @@ "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^16.3.2", "@testing-library/user-event": "^14.6.1", + "@wordpress/jest-preset-default": "file:../../packages/jest-preset-default", "@wordpress/scripts": "file:../../packages/scripts", "babel-jest": "^29.7.0", + "glob": "^7.1.2", "jest": "^29.6.2", "jest-environment-jsdom": "^30.2.0", "jest-jasmine2": "^29.6.2", From 8d22cbc7bba2fff66040463b3f9e085b95a48af1 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Tue, 21 Apr 2026 09:55:35 +0530 Subject: [PATCH 10/10] Remove unused dependency from root --- package-lock.json | 1 - package.json | 1 - 2 files changed, 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index ee5499d7f6907a..6558739c520546 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,6 @@ "tools/api-docs" ], "devDependencies": { - "@apidevtools/json-schema-ref-parser": "11.6.4", "@babel/core": "7.25.7", "@emotion/babel-plugin": "11.13.5", "@emotion/is-prop-valid": "1.4.0", diff --git a/package.json b/package.json index 087d03bdffba43..bb59621be112bb 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,6 @@ "IS_GUTENBERG_PLUGIN": true }, "devDependencies": { - "@apidevtools/json-schema-ref-parser": "11.6.4", "@babel/core": "7.25.7", "@emotion/babel-plugin": "11.13.5", "@emotion/is-prop-valid": "1.4.0",