File size: 1,182 Bytes
b91e262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'

const cacheComponentsEnabled = process.env.__NEXT_CACHE_COMPONENTS === 'true'

describe('dev-output', () => {
  const { next, isTurbopack } = nextTestSetup({
    files: __dirname,
  })

  it('shows Cache Components indicator when enabled', async () => {
    await next.fetch('/')
    await retry(async () => {
      const output = next.cliOutput

      if (cacheComponentsEnabled) {
        if (isTurbopack) {
          expect(output).toContain('Next.js')
          expect(output).toContain('Turbopack')
          expect(output).toContain('Cache Components')
        } else {
          expect(output).toContain('Next.js')
          expect(output).toContain('webpack')
          expect(output).toContain('Cache Components')
        }
      } else {
        // When cache components env is not set, should not show the indicator
        expect(output).toContain('Next.js')
        if (isTurbopack) {
          expect(output).toContain('Turbopack')
        } else {
          expect(output).toContain('webpack')
        }
        expect(output).not.toContain('Cache Components')
      }
    })
  })
})