Skip to content

bug: Jest 30 Support: Documentation Claims Support but Version Check Blocks It #6599

@michaelsouellette

Description

@michaelsouellette

Prerequisites

Stencil Version

+4.42.1

Current Behavior

The Stencil documentation for v4.43.0 states that Jest 30+ is supported (https://stenciljs.com/docs/testing/jest), however, when running tests with Jest 30.2.0, Stencil's test runner throws an error requiring Jest 29 or lower.

This creates a discrepancy between the documentation and the actual implementation, preventing projects from upgrading to Jest 30 while using Stencil.

Actual Behavior

Stencil throws the following error and refuses to run tests:

[13:37.3]  @stencil/core
[13:37.5]  v4.43.0 👒

[ ERROR ]  Please install supported versions of dev dependencies with either npm or yarn.
           npm install --save-dev @types/jest@29 jest@29

The test runner exits with a non-zero status code without running any tests.

Root Cause Analysis

The error appears to be coming from hardcoded version checking in Stencil's testing module that only accepts Jest 27-29, despite the documentation being updated to reflect Jest 30+ support.

Impact

This issue is blocking:

  • Projects using Nx (which defaults to Jest 30 in recent versions)
  • Projects that need Jest 30 features or bug fixes
  • Migration paths from older Stencil versions that expect documentation to be accurate

Workarounds Attempted

  1. ✅ Added explicit testing configuration to stencil.config.ts
  2. ✅ Used Stencil CLI directly (not through Nx executors)
  3. ✅ Configured Jest preprocessor correctly
  4. ✅ Updated to latest Stencil version (4.43.0)
  5. ❌ None of these resolve the version check error

The only workaround is downgrading to Jest 29, which may break other dependencies in modern monorepos.

Expected Behavior

Based on the documentation at https://stenciljs.com/docs/testing/jest, Jest 30+ should be fully supported. Tests should run without version compatibility errors.

Proposed Solution

  1. Update the version checking code in @stencil/core/testing to accept Jest 30+
  2. Add Jest 30 to CI testing matrix to prevent future regressions
  3. If Jest 30 support is not yet ready, update documentation to reflect accurate version requirements

System Info

- **@stencil/core**: v4.43.0 (also reproduced in v4.42.1)
- **jest**: v30.2.0
- **@types/jest**: v30.0.0
- **Node**: v20+ (latest LTS)
- **OS**: macOS (also reproducible on other platforms)

Steps to Reproduce

  1. Install Stencil 4.43.0 and Jest 30.2.0:

    npm install @stencil/core@4.43.0 jest@30.2.0 @types/jest@30.0.0
  2. Create a basic stencil.config.ts with testing configuration:

    import { Config } from '@stencil/core';
    
    export const config: Config = {
      namespace: 'test',
      testing: {
        browserHeadless: 'shell',
        testPathIgnorePatterns: ['/node_modules/', '/dist/'],
        coveragePathIgnorePatterns: ['/node_modules/', '/dist/'],
        transform: {
          '^.+\\.(ts|tsx)$': ['@stencil/core/testing/jest-preprocessor', {}]
        },
        moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
        testRegex: '(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$'
      }
    };
  3. Run Stencil tests:

    stencil test --spec

Code Reproduction URL

https://github.com/michaelsouellette/stencil-jest-30-reproduction

Additional Information

Additional Context

This issue has been reproduced across multiple Stencil versions (4.42.1, 4.43.0) suggesting the documentation was updated in anticipation of support but the actual implementation wasn't completed.

The documentation should either:

  • Be corrected to show Jest 29 as the maximum supported version, OR
  • The version checking code should be updated to allow Jest 30+

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stencil v5This is slated for Stencil v5 (Release date TBD)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions