Files
vercel__next.js/test/e2e/worker-react-refresh/worker-react-refresh.test.tsx
Will Binns-Smith dba20c3d16 Turbopack: Add react refresh runtime stubs to workers (#78433)
Analogous to https://github.com/vercel/next.js/pull/15145, this adds
no-op stubs to take the place of the react refresh runtime in workers.

This prevents workers from failing when they use react components, such
as in non-dom react renderers like
[`@react-three/offscreen`](https://github.com/pmndrs/react-three-offscreen).

This code is only added in dev, and the base runtime was parameterized
to allow this.

Test Plan:
- Manually create a worker that uses `@react-three/offscreen` to render
a component and use it in dev.
- [x] Automated test
2025-04-24 11:39:58 -07:00

30 lines
758 B
TypeScript

import { nextTestSetup } from 'e2e-utils'
describe('worker-react-refresh', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
dependencies: require('./package.json').dependencies,
})
if (skipped) {
return
}
it('does not cause any runtime errors', async () => {
const pageErrors: unknown[] = []
await next.browser('/', {
beforePageLoad: (page) => {
page.on('pageerror', (error: unknown) => {
pageErrors.push(error)
})
},
})
// If the worker runtime does not implement the React Refresh API (i.e.
// `register` and `signature`), transformed React code attempts to call it
// and fails.
expect(pageErrors).toBeEmpty()
})
})