Commit 20a7ffa
ci: jest ts jest compatibility (#2247)
* fix(faustwp-core): update ts-jest to ^29.1.1
ts-jest 27.x only supports Jest 27.x, but we're using Jest 29.x.
This version mismatch caused test failures with the error:
"process() or/and processAsync() method of code transformer..."
Updated to ts-jest ^29.1.1 to match @faustwp/cli.
* fix: update deprecated ts-jest globals config to transform syntax
ts-jest deprecated the globals config in favor of transform options.
Updated all jest.config.js files to use the new syntax:
Before:
globals: { 'ts-jest': { useESM: true } }
After:
transform: { '^.+\\.tsx?$': ['ts-jest', { useESM: true }] }
* fix: disable default coverage collection in jest configs
Coverage collection via babel-plugin-istanbul has compatibility
issues with Node.js 22 due to deprecated util.promisify usage in
test-exclude. Disabling collectCoverage by default allows tests
to run successfully. Coverage is still collected when explicitly
requested via test:coverage:ci scripts.
* fix: add coverage to .eslintignore files
Add coverage directory to .eslintignore to prevent prettier format
checks from failing on generated coverage report files.
- Create packages/faustwp-cli/.eslintignore with dist, node_modules, coverage
- Update packages/faustwp-core/.eslintignore to include coverage
* fix(faustwp-core): replace inline snapshots with toEqual in Toolbar tests
toMatchInlineSnapshot() with expected content is not supported in
newer Jest/Babel versions. Replace with toEqual() using explicit
array comparisons for toolbar node content validation.
* test(faustwp-core): update snapshots for fast-xml-parser 5.x
fast-xml-parser 5.x changed XML quote escaping behavior, outputting
unescaped quotes instead of escaped entities. Update test snapshots
to match the new output format.
* chore: regenerate package-lock.json
Regenerate lockfile after updating ts-jest dependency to ensure
correct versions are locked.
* fix: regenerate package-lock.json to fix npm ci sync error
The previous lockfile was missing dependencies that npm ci requires:
- glob@11.1.0, glob@10.5.0
- jackspeak@4.1.1, jackspeak@3.4.3
- minimatch@10.1.1, minimatch@9.0.5
- path-scurry@2.0.1, path-scurry@1.11.1
- @isaacs/brace-expansion@5.0.0, brace-expansion@2.0.2
- @isaacs/balanced-match@4.0.1
- lru-cache@11.2.5, lru-cache@10.4.3
This caused CI to fail with:
"npm ci can only install packages when your package.json and
package-lock.json are in sync"
* fix: remove glob overrides to resolve npm ci sync error
The glob overrides in root and faustwp-core package.json were forcing
glob to v10.5.0, but faustwp-cli explicitly requires glob v11.1.0.
This created an unresolvable conflict causing npm ci to fail with:
"Missing: glob@11.1.0 from lock file"
Remove the glob overrides and regenerate package-lock.json to allow
npm to resolve glob versions naturally for each package.
* test(blocks): suppress expected console.error in hook error test
The test for useBlocksTheme throwing when used outside provider was
logging expected React errors to console.error, which caused CI to
exit with code 1 even though all tests passed.
* test(faustwp-cli): fix validateNextWordPressUrl test expectations
The test expected console.log to be called with the full error message
as a single argument, but errorLog() passes the message prefix and
details as separate arguments.
* fix(ci): use docker exec for MySQL health check
The Wait for db step used $MYSQL_ROOT_PASSWORD which was never defined,
causing intermittent test failures. Use docker compose exec to connect
directly to the container instead of from the host.
Bug introduced in 6e5ef28 (May 2024).
* fix(ci): pin MySQL 8.0 and enable native auth for SSL compatibility
MySQL 8.4+ has stricter SSL requirements causing "self-signed certificate"
errors in CI. Pin to MySQL 8.0 and use mysql_native_password authentication
to ensure compatibility with the WordPress test containers.
Also removes deprecated docker-compose version attribute.
* fix(ci): disable SSL for MySQL connections in test setup
Add --ssl-mode=DISABLED to mysql/mysqladmin commands in install-wp-tests.sh
to prevent SSL certificate verification errors in CI environment.
* fix(ci): disable SSL for MySQL connections in test setup
Add --skip-ssl to mysql/mysqladmin commands in install-wp-tests.sh
to prevent SSL certificate verification errors in CI environment.
Note: Using --skip-ssl instead of --ssl-mode=DISABLED for compatibility
with MariaDB client (default-mysql-client) in WordPress containers.
* fix: add test-exclude override for Node.js 22 coverage compatibility
The test-exclude@6.0.0 package uses util.promisify in a way that's
incompatible with Node.js 22, causing coverage collection to fail
with "TypeError: The 'original' argument must be of type function".
This adds an npm override to force test-exclude@^7.0.1 which fixes
the Node.js 22 compatibility issue.
* fix coverage test
* Update FaustWP CLI Jest setup
Add Jest as a dev dependency for the faustwp-cli package and simplify the ts-jest transform config: replace the previous useESM object with an explicit tsconfig option (tsconfig.json). This ensures ts-jest uses the project TypeScript config and keeps the Jest setup concise.
* Enable ESM support for ts-jest in CLI tests
Add useESM: true to the ts-jest transformer in packages/faustwp-cli/jest.config.js so TypeScript tests run in ESM mode. This ensures ts-jest handles native ESM imports/exports properly while continuing to use the existing tsconfig.json.
* Update ts-jest for Node 22 compat
* Add TypeScript typings and suppress InnerBlocks error
Add a // @ts-expect-error before InnerBlocks.Content to silence incompatible React types across versions, and tighten TypeScript annotations in errorLoggingLink: specify the Observable observer shape and explicit types for next and error handlers (FetchResult / unknown). These changes address TS type errors and improve type safety without altering runtime behavior.
* Update errorLoggingLink.ts
* fix: add transformIgnorePatterns to Jest configs for ESM compatibility
- Add transformIgnorePatterns to faustwp-core and blocks Jest configs
to transform @apollo/client, ts-invariant, tslib, and zen-observable-ts
- Add ts-invariant as explicit devDependency in faustwp-core to fix
missing transitive dependency issue
This resolves Jest test failures on Node.js 22 where ESM modules from
@apollo/client were not being transformed correctly during test runs.
* fix: add @apollo/client transitive dependencies for Jest compatibility
Add explicit devDependencies for @apollo/client's transitive dependencies
in faustwp-core. Due to npm workspace hoisting, the local @apollo/client
(v3.14.0) cannot resolve its dependencies when they're hoisted to the
root node_modules with different versions.
Added dependencies:
- @graphql-typed-document-node/core
- @wry/caches, @wry/equality, @wry/trie
- graphql-tag, hoist-non-react-statics
- optimism, prop-types, rehackt
- symbol-observable, tslib, zen-observable-ts
This fixes "Cannot find module 'zen-observable-ts'" and similar errors
that caused 10 faustwp-core and 3 blocks test suites to fail in CI.
* Update action.yml
* fix: run coverage tests manually to avoid test-exclude/glob incompatibility
The jest-coverage-report-action's skip-step: install parameter was not
working, causing npm install to run and override the locked dependencies.
This resulted in test-exclude@6.0.0 being used with glob v11, which fails
on Node 22 due to promisify incompatibility.
This change:
- Runs coverage tests manually using npm scripts (respects npm ci deps)
- Uses coverage-file parameter to provide pre-generated reports
- Upgrades action to v2.3.1 and uses skip-step: all
* fix: run coverage tests manually to avoid test-exclude/glob incompatibility
The jest-coverage-report-action's skip-step: install parameter was not
working, causing npm install to run and override the locked dependencies.
This resulted in test-exclude@6.0.0 being used with glob v11, which fails
on Node 22 due to promisify incompatibility.
This change:
- Runs coverage tests manually using npm scripts (respects npm ci deps)
- Uses coverage-file parameter to provide pre-generated reports
- Upgrades action to v2.3.1 and uses skip-step: all
---------
Co-authored-by: ahuseyn <huseyn.aghayev@wpengine.com>1 parent 765a266 commit 20a7ffa
21 files changed
Lines changed: 17083 additions & 15324 deletions
File tree
- .github
- actions/run-coverage
- workflows
- packages
- block-editor-utils
- src/components
- blocks
- tests/components
- faustwp-cli
- tests/healthCheck
- faustwp-core
- src/apollo
- tests
- components/Toolbar
- config
- server/sitemaps/__snapshots__
- plugins/faustwp
- bin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
15 | 22 | | |
16 | | - | |
17 | 23 | | |
18 | | - | |
| 24 | + | |
| 25 | + | |
19 | 26 | | |
20 | 27 | | |
21 | | - | |
| 28 | + | |
| 29 | + | |
22 | 30 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
0 commit comments