Files
next.js/test/e2e/react-compiler/react-compiler.test.ts
T
Janka UrygaandGitHub 8747e235d9 fix: race condition in CLI output in react-compiler test (#65909)
the 'should show an experimental warning' test in
`react-compiler-test.ts` has been randomly flaking for me:

```
    Expected substring: "Experiments (use with caution)"
    Received string:    " ⚠ `experimental.ppr` has been defaulted to `true` because `__NEXT_EXPERIMENTAL_PPR` was set to `true` during testing.
     ⚠ `experimental.ppr` has been defaulted to `true` because `__NEXT_EXPERIMENTAL_PPR` was set to `true` during testing.
      ▲ Next.js 14.3.0-canary.69
      - Local:        http://localhost:40095
    "
```
when the actual CLI output is:
```
 ⚠ `experimental.ppr` has been defaulted to `true` because `__NEXT_EXPERIMENTAL_PPR` was set to `true` during testing.
 ⚠ `experimental.ppr` has been defaulted to `true` because `__NEXT_EXPERIMENTAL_PPR` was set to `true` during testing.
  ▲ Next.js 14.3.0-canary.69
  - Local:        http://localhost:40095
  - Experiments (use with caution):
    · reactCompiler
```
which indicates that we're reading the CLI output too early
2024-05-18 00:20:53 +02:00

40 lines
1.1 KiB
TypeScript

import { nextTestSetup, FileRef } from 'e2e-utils'
import { retry } from 'next-test-utils'
import { join } from 'path'
describe.each(
['default', process.env.TURBOPACK ? undefined : 'babelrc'].filter(Boolean)
)('react-compiler %s', (variant) => {
const { next } = nextTestSetup({
files:
variant === 'babelrc'
? __dirname
: {
app: new FileRef(join(__dirname, 'app')),
'next.config.js': new FileRef(join(__dirname, 'next.config.js')),
},
dependencies: {
'babel-plugin-react-compiler': '0.0.0-experimental-4690415-20240515',
},
})
it('should show an experimental warning', async () => {
await retry(() => {
expect(next.cliOutput).toContain('Experiments (use with caution)')
expect(next.cliOutput).toContain('reactCompiler')
})
})
it('should render', async () => {
const browser = await next.browser('/')
await retry(async () => {
const text = await browser
.elementByCss('#react-compiler-enabled-message')
.text()
expect(text).toMatch(/React compiler is enabled with \d+ memo slots/)
})
})
})