Unverified Commit f5bef049 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Polish error icon for error log (#55618)

### After 💅 

<img width="109" alt="image" src="https://github.com/vercel/next.js/assets/4800338/f90d15a1-ac6e-4fe1-8241-d9e40e9d2e0e">

 ### Before 

<img width="143" alt="image" src="https://github.com/vercel/next.js/assets/4800338/fbc09a29-cac2-459d-8a96-d1a5948947cc">
parent 23c3ea44
...@@ -2,7 +2,7 @@ import chalk from '../../lib/chalk' ...@@ -2,7 +2,7 @@ import chalk from '../../lib/chalk'
export const prefixes = { export const prefixes = {
wait: chalk.white(chalk.bold('○')), wait: chalk.white(chalk.bold('○')),
error: chalk.red(chalk.bold('X')), error: chalk.red(chalk.bold('⨯')),
warn: chalk.yellow(chalk.bold('⚠')), warn: chalk.yellow(chalk.bold('⚠')),
ready: chalk.bold('▲'), // no color ready: chalk.bold('▲'), // no color
info: chalk.white(chalk.bold(' ')), info: chalk.white(chalk.bold(' ')),
......
...@@ -29,13 +29,13 @@ createNextDescribe( ...@@ -29,13 +29,13 @@ createNextDescribe(
it('logs the error correctly', async () => { it('logs the error correctly', async () => {
await next.fetch('/') await next.fetch('/')
const output = stripAnsi(next.cliOutput) const output = stripAnsi(next.cliOutput)
await check( await check(() => {
() => stripAnsi(next.cliOutput), expect(stripAnsi(next.cliOutput)).toMatch(
new RegExp( /middleware.js \(\d+:\d+\) @ Object.default \[as handler\]/
`middleware.js \\(\\d+:\\d+\\) @ Object.default \\[as handler\\]\\s*\\w+\\s*boom`,
'm'
) )
) expect(stripAnsi(next.cliOutput)).toMatch(/boom/)
return 'success'
}, 'success')
expect(output).not.toContain( expect(output).not.toContain(
'webpack-internal:///(middleware)/./middleware.js' 'webpack-internal:///(middleware)/./middleware.js'
) )
...@@ -103,13 +103,13 @@ createNextDescribe( ...@@ -103,13 +103,13 @@ createNextDescribe(
it('logs the error correctly', async () => { it('logs the error correctly', async () => {
await next.fetch('/') await next.fetch('/')
const output = stripAnsi(next.cliOutput) const output = stripAnsi(next.cliOutput)
await check( await check(() => {
() => stripAnsi(next.cliOutput), expect(stripAnsi(next.cliOutput)).toMatch(
new RegExp( /middleware.js \(\d+:\d+\) @ eval/
`middleware.js \\(\\d+:\\d+\\) @ eval\\s*\\w+\\s*test is not defined`,
'm'
) )
) expect(stripAnsi(next.cliOutput)).toMatch(/test is not defined/)
return 'success'
}, 'success')
expect(output).not.toContain( expect(output).not.toContain(
'webpack-internal:///(middleware)/./middleware.js' 'webpack-internal:///(middleware)/./middleware.js'
) )
...@@ -141,13 +141,13 @@ createNextDescribe( ...@@ -141,13 +141,13 @@ createNextDescribe(
it('logs the error correctly', async () => { it('logs the error correctly', async () => {
await next.fetch('/') await next.fetch('/')
const output = stripAnsi(next.cliOutput) const output = stripAnsi(next.cliOutput)
await check( await check(() => {
() => stripAnsi(next.cliOutput), expect(stripAnsi(next.cliOutput)).toMatch(
new RegExp( /middleware.js \(\d+:\d+\) @ <unknown>/
`middleware.js \\(\\d+:\\d+\\) @ <unknown>\\s*\\w+\\s*booooom!`,
'm'
) )
) expect(stripAnsi(next.cliOutput)).toMatch(/booooom!/)
return 'success'
}, 'success')
expect(output).not.toContain( expect(output).not.toContain(
'webpack-internal:///(middleware)/./middleware.js' 'webpack-internal:///(middleware)/./middleware.js'
) )
...@@ -247,8 +247,14 @@ createNextDescribe( ...@@ -247,8 +247,14 @@ createNextDescribe(
it('logs the error correctly', async () => { it('logs the error correctly', async () => {
await next.fetch('/') await next.fetch('/')
expect(next.cliOutput).toContain(`Expected '{', got '}'`) await check(async () => {
expect(next.cliOutput.split(`Expected '{', got '}'`).length).toEqual(2) expect(next.cliOutput).toContain(`Expected '{', got '}'`)
expect(next.cliOutput.split(`Expected '{', got '}'`).length).toEqual(
2
)
return 'success'
}, 'success')
}) })
it('renders the error correctly and recovers', async () => { it('renders the error correctly and recovers', async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment