Skip to content

BREAKING: ESM only, Support for Storybook 10 and Jest 30#571

Merged
yannbf merged 31 commits intonextfrom
yann/experiment-with-esm
Oct 20, 2025
Merged

BREAKING: ESM only, Support for Storybook 10 and Jest 30#571
yannbf merged 31 commits intonextfrom
yann/experiment-with-esm

Conversation

@yannbf
Copy link
Member

@yannbf yannbf commented Jun 30, 2025

Closes #

What I did

This PR refactors the test-runner so it doesn't use jest-playwright-preset directly, allowing it to support Jest 30.
Additionally it adds support for Storybook 10, and as a requirement it becomes ESM only, therefore having breaking changes. It will only support Storybook 10 and higher

Checklist for Contributors

Manual testing

  • Set up or choose a project using Jest 30
  • Add Storybook 10: npx storybook@next init
  • Add the test-runner npm install --save-dev @storybook/test-runner@0.23.1--canary.af6bf62.0
  • Test things out, see whether npm run test-storybook works as intended
    • normal run
    • watch mode
    • pass some Jest 30 flags
  • More info about Jest 30 at https://jestjs.io/blog/2025/06/04/jest-30#breaking-changes

Documentation

  • Add or update documentation reflecting your changes in this repository
  • Request documentation updates in the test-runner docs website

Checklist for Maintainers

  • Make sure this PR contains one of the labels below:

    Available labels
    • skip-release: Skip any releases, e.g., documentation only changes, CI config etc.
    • patch: Upgrade patch version (e.g. 0.0.x)
    • minor: Upgrade patch version (e.g. 0.x.0)
    • major: Upgrade patch version (e.g. x.0.0)

@yannbf yannbf added the patch Increment the patch version when merged label Jun 30, 2025
@yannbf yannbf requested a review from kasperpeulen as a code owner June 30, 2025 13:49
@yannbf yannbf changed the title wip Jest 30 experiment Jul 7, 2025
@yannbf yannbf force-pushed the yann/experiment-with-esm branch from 55459a1 to 6833c21 Compare July 9, 2025 09:47
ndelangen and others added 12 commits July 9, 2025 14:05
…able module type, and upgrade Jest and SWC dependencies. Adjust Playwright setup for ESM compatibility and clean up TypeScript ignore comments across multiple files.
…e, and add Vitest configuration. Update test files to use Vitest instead of Jest, including snapshot updates and async test handling. Adjust Playwright and Storybook integration for improved compatibility.
@yannbf yannbf force-pushed the yann/experiment-with-esm branch from 545c0fd to fe87de1 Compare July 24, 2025 09:32
@yannbf yannbf changed the title Jest 30 experiment BREAKING: ESM only, Support for Storybook 10 and Jest 30 Oct 15, 2025
Copy link
Member

@Sidnioulz Sidnioulz left a comment

Choose a reason for hiding this comment

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

Had to monkey patch a few things, but then got tests to pass on a fresh Nextjs x Turbopack repo.

Watch mode works, tests pass and fail when expected.

I'll give more feedback later as I'm battling with Istambul to test coverage.

@Sidnioulz
Copy link
Member

Not sure if these are known issues or SB10 regressions, but the follow test-runner features don't work:

    toMatchSnapshot() must be called during the test

      14 |     const elementHandler = await page.$('#storybook-root');
      15 |     const innerHTML = await elementHandler!.innerHTML();
    > 16 |     expect(innerHTML).toMatchSnapshot();
         |                       ^
      17 |   },
      18 | };
      19 | export default config;

This seems to be something Jest is responsible for rather than Playwright. Has anything changed within Jest that could be relevant here?

TypeError: Cannot read properties of undefined (reading '_counters')

      15 |
      16 |     const image = await page.screenshot();
    > 17 |     expect(image).toMatchImageSnapshot();
         |                   ^
      18 |
      19 |     const elementHandler = await page.$('#storybook-root');
      20 |     const innerHTML = await elementHandler!.innerHTML();

jest-image-snapshot should support Jest 30. I'm not sure if this has to do with when postVisit is called.

Copy link
Member

@Sidnioulz Sidnioulz left a comment

Choose a reason for hiding this comment

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

Ejecting does not work (import path to fix).

Once the path is fixed, config overrides work. I can change the list of files to treat as ESM or the transform functions.

@ndelangen ndelangen requested a review from Sidnioulz October 20, 2025 08:52
@ndelangen ndelangen mentioned this pull request Oct 20, 2025
3 tasks
@ndelangen ndelangen added minor Increment the minor version when merged and removed patch Increment the patch version when merged labels Oct 20, 2025
@ndelangen
Copy link
Member

ndelangen commented Oct 20, 2025

@jasikpark @IanVS This is the PR we're going to go for for SB10, can you assist testing this?
We've tested this on the storybook repo already.

This is the canary version of this PR:
@storybook/test-runner@0.23.1--canary.e482a2f.0

🙏

@yannbf yannbf merged commit 9def1de into next Oct 20, 2025
9 checks passed
@IanVS
Copy link
Member

IanVS commented Oct 20, 2025

Nice! Updating from the canary of the other PR to this one seems to have cut down on our dependencies quite a lot:

image

It seems to be working well in our "degenerate" codebase. 😆

@gregberge
Copy link

I see you are working on v10 support here, if it helps, tests are failing on v10: https://github.com/argos-ci/argos-javascript/actions/runs/18688211014/job/53286617759?pr=240

@IanVS
Copy link
Member

IanVS commented Oct 21, 2025

@gregberge it would probably be good to open an issue to report this problem, and share any relevant config there.

@Sidnioulz
Copy link
Member

I see you are working on v10 support here, if it helps, tests are failing on v10: https://github.com/argos-ci/argos-javascript/actions/runs/18688211014/job/53286617759?pr=240

@gregberge it would probably be good to open an issue to report this problem, and share any relevant config there.

I think it's very much relevant to this PR. @yannbf has removed the process endpoint. The Jest 30 doc says:

Asynchronous transpilation can fall back to the synchronous process call if processAsync is unimplemented, but synchronous transpilation cannot use the asynchronous processAsync call. If your codebase is ESM only, implementing the async variants are sufficient. Otherwise, if any code is loaded through require (including createRequire from within ESM), then you need to implement the synchronous process variant.

As we're moving to ESM only, do we still support our callees writing CJS code and importing us in CJS codebases? If so, we might need to preserve the sync process endpoint.

@yannbf yannbf mentioned this pull request Oct 28, 2025
@gregberge
Copy link

gregberge commented Oct 30, 2025

@yannbf can we add back the synchronous process?

Nevermind, it was because the source code was in JS and not TS. I migrated on TS and it's fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Increment the minor version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants