Files
Jiachi LiuandGitHub c5207751a2 Polish turbopack start logging (#57203)
Bring a tiny util to get a `(turbo)` label after next.js info for turbopack dev-server logging and also remove the disclaimer of "thank you for trying".

### After

<img width="597" alt="image" src="https://github.com/vercel/next.js/assets/4800338/c3658775-3ce6-48fc-8128-7baebe9f104b">


### Before

<img width="597" alt="image" src="https://github.com/vercel/next.js/assets/4800338/d008dd0b-4c58-4612-b1c4-d5e97e041c1b">


* Fixes the bad dim color
* Colorize the `Next.js (turbo)` label
* Move the learning link down after start message
* Use Log util to format logs
* Remove "v13" related text
2023-10-23 02:53:40 +00:00

102 lines
2.5 KiB
TypeScript

import {
check,
findPort,
killApp,
launchApp,
renderViaHTTP,
} from 'next-test-utils'
import fs from 'fs-extra'
import { join } from 'path'
describe('turbopack unsupported features log', () => {
if (process.env.TURBOPACK) {
const appDir = join(__dirname, 'app')
it('should not warn by default', async () => {
let output = ''
const appPort = await findPort()
const app = await launchApp(appDir, appPort, {
onStdout(msg) {
output += msg
},
onStderr(msg) {
output += msg
},
})
try {
expect(await renderViaHTTP(appPort, '/')).toContain('hello world')
expect(output).toContain('(turbo)')
expect(output).not.toContain(
'You are using configuration and/or tools that are not yet'
)
} finally {
await killApp(app).catch(() => {})
}
})
const nextConfigPath = join(appDir, 'next.config.js')
it('should not warn with empty next.config.js', async () => {
let output = ''
await fs.writeFile(nextConfigPath, `module.exports = {}`)
const appPort = await findPort()
const app = await launchApp(appDir, appPort, {
onStdout(msg) {
output += msg
},
onStderr(msg) {
output += msg
},
})
try {
expect(output).toContain('(turbo)')
expect(output).not.toContain(
'You are using configuration and/or tools that are not yet'
)
expect(await renderViaHTTP(appPort, '/')).toContain('hello world')
} finally {
await killApp(app).catch(() => {})
await fs.remove(nextConfigPath)
}
})
it('should warn with next.config.js with unsupported field', async () => {
let output = ''
await fs.writeFile(
nextConfigPath,
`module.exports = {
experimental: {
urlImports: true
}
}`
)
const appPort = await findPort()
const app = await launchApp(appDir, appPort, {
onStdout(msg) {
output += msg
},
onStderr(msg) {
output += msg
},
})
try {
await check(() => {
expect(output).toContain('(turbo)')
expect(output).toContain(
'You are using configuration and/or tools that are not yet'
)
return 'success'
}, /success/)
} finally {
await killApp(app).catch(() => {})
await fs.remove(nextConfigPath)
}
})
} else {
it.skip('turbopack only', () => {})
}
})