Files
Jiwon ChoiandGitHub 1511433212 fix(next): next build --debug log output layout is broken (#63193)
### Why?

The output layout breaks when running `next build --debug`

#### Current

```sh
 ✓ Generating static pages (10/10) 
   Finalizing page optimization  .   Collecting build traces  .Redirects

┌ source: /:path+/
├ destination: /:path+
└ permanent: true
 

 ✓ Collecting build traces    
 ✓ Finalizing page optimization    
```

#### Expected

```sh
✓ Generating static pages (4/4) 
   Finalizing page optimization ...
   Collecting build traces ...


Redirects
┌ source: /:path+/
├ destination: /:path+
└ permanent: true
```

### How?

Moved the `debug` output right above the `routes` output.
Also, ensured that the output layout has a consistent number of line
breaks (example below marked as `>`):

> Two line breaks for the next `option`, a single line break within the
same content.

```sh
   Collecting build traces ...
>
>
Redirects
┌ source: /:path+/
├ destination: /:path+
└ permanent: true
>
┌ source: /redirects
├ destination: /
└ permanent: true
>
>
Headers
┌ source: /
└ headers:
  └ x-custom-headers: headers
>
>
Rewrites
┌ source: /rewrites
└ destination: /
>
>
Route (app)                              Size     First Load JS
┌ ○ /                                    141 B          86.2 kB
└ ○ /_not-found                          876 B          86.9 kB
```

Fixes #63192

---------
2024-04-02 15:05:28 -07:00

42 lines
1.3 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
import stripAnsi from 'strip-ansi'
describe('production - app dir - build output', () => {
const { next } = nextTestSetup({
files: __dirname,
})
let output = ''
beforeAll(() => {
output = stripAnsi(next.cliOutput)
})
it('should only log app routes', async () => {
expect(output).toContain('Route (app)')
expect(output).not.toContain('Route (pages)')
expect(output).not.toContain('/favicon.ico')
})
it('should always log version first then the rest jobs', async () => {
const indexOfVersion = output.indexOf('▲ Next.js')
const indexOfStartCompiling = output.indexOf(
'Creating an optimized production build'
)
const indexOfLinting = output.indexOf(
'Linting and checking validity of types'
)
expect(indexOfVersion).toBeLessThan(indexOfLinting)
expect(indexOfStartCompiling).toBeLessThan(indexOfLinting)
})
it('should match the expected output format', async () => {
expect(output).toContain('Size')
expect(output).toContain('First Load JS')
expect(output).toContain('+ First Load JS shared by all')
expect(output).toContain('└ other shared chunks (total)')
// output type
expect(output).toContain('○ (Static) prerendered as static content')
})
})