Skip to content

Conversation

@FelixK-Witt
Copy link

@FelixK-Witt FelixK-Witt commented Dec 5, 2025

Close #32968

User facing changelog

Fixes Next.js 16.0.3+ component testing compatibility by proactively calling the installBindings() API.

Additional details

Starting with Next.js 16.0.3, the Turbopack bundler requires tools to proactively call installBindings() to ensure SWC bindings are loaded before webpack loaders (like next-swc-loader) attempt to use them. Without this call, users encounter the error: Error: bindings not loaded yet. Either call loadBindingsto wait for them to be available or ensure thatinstallBindings has already been called..

This PR adds the required installBindings() call in the Next.js webpack dev server handler, wrapped in a try-catch block to maintain backward compatibility with Next.js versions prior to 16.0.3 where this API doesn't exist.

Steps to test

  1. Create a Next.js 16.0.3+ project with component testing
  2. Make sure a next.config.js exists (not next.config.ts)
  3. Run cypress open --component
  4. Component tests should compile without errors

Also here's an example repo with the patch applied: https://github.com/FelixK-Witt/cypress-next-16-component-testing

How has the user experience changed?

Users on Next.js 16.0.3+ can now successfully run component tests without encountering SWC binding errors.

See: vercel/next.js#85787

Fixes cypress-io#32968

Starting with Next.js 16.0.3, the Turbopack bundler requires tools to
proactively call installBindings() to ensure SWC bindings are loaded
before webpack loaders attempt to use them.

This change adds a call to installBindings() in the Next.js handler
before loading the webpack configuration. The call is wrapped in a
try-catch to maintain backward compatibility with Next.js versions
prior to 16.0.3 where this API does not exist.

Changes:
- Add installBindings() call in getNextJsPackages()
- Make getNextJsPackages() async to properly await installBindings()
- Add test coverage for the installBindings logic
- Add debug logging for troubleshooting

See: vercel/next.js#85787
@CLAassistant
Copy link

CLAassistant commented Dec 5, 2025

CLA assistant check
All committers have signed the CLA.

@cypress-app-bot
Copy link
Collaborator

@AtofStryker
Copy link
Contributor

@FelixK-Witt thank you for opening a PR to fix this! Changes look good to me, but we need a way to test them in CI/CD. Since there really isn't a great way to unit test this currently, I am going to update the nextjs-configured and nextjs-unconfigured system-tests which will implicitly test this change. Since the test isn't obvious, I will call it out in the nextjs-configured README.

cc @jennifer-shehane

Copy link
Contributor

@AtofStryker AtofStryker left a comment

Choose a reason for hiding this comment

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

The source changes look good to me. @jennifer-shehane i updated nextjs-configured and nextjs-unconfigured to next 16 to get test coverage here. Are you able to review those changes as well as the change entry?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow for Next.js Component testing to work without Next config

5 participants