Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 5 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"@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",
Expand All @@ -55,8 +54,6 @@
"@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",
Expand Down Expand Up @@ -95,8 +92,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",
Comment thread
manzoorwanijk marked this conversation as resolved.
Resolved
"jsonc-parser": "3.3.1",
Expand All @@ -113,7 +108,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",
Expand Down Expand Up @@ -203,9 +197,9 @@
"test:performance:debug": "npm exec --workspace @wordpress/performance-tests -- wp-scripts test-playwright --config playwright.config.ts --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",
Expand All @@ -215,8 +209,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"
},
Expand Down Expand Up @@ -260,6 +254,7 @@
"test/e2e",
"test/performance",
"test/storybook-playwright",
"test/unit",
"tools/api-docs"
]
}
19 changes: 16 additions & 3 deletions test/unit/jest.config.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
46 changes: 46 additions & 0 deletions test/unit/package.json
Original file line number Diff line number Diff line change
@@ -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",
Comment thread
manzoorwanijk marked this conversation as resolved.
Resolved
"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"
Comment thread
manzoorwanijk marked this conversation as resolved.
Resolved
},
"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"
}
}
20 changes: 20 additions & 0 deletions test/unit/tsconfig.json
Comment thread
manzoorwanijk marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$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": []
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
{ "path": "storybook" },
{ "path": "test/e2e" },
{ "path": "test/storybook-playwright" },
{ "path": "test/performance" }
{ "path": "test/performance" },
{ "path": "test/unit" }
],
"files": []
}
Loading