rsnext/test/development/watch-config-file/index.test.ts
Jan Kaifer 2c9b484fc1
Auto-restart dev server when next.config.js changes (#47912)
This is a follow-up PR on https://github.com/vercel/next.js/pull/46577
after it got nasty conflicts.

Basically, just restart `dev` when `next.config.ts` it will just restart
instead of printing that message asking you to restart.
fix NEXT-639
2023-04-05 18:17:54 +00:00

54 lines
1.3 KiB
TypeScript

import { createNextDescribe } from 'e2e-utils'
import { check } from 'next-test-utils'
createNextDescribe(
'watch-config-file',
{
files: {
'pages/index.js': `
export default function Page() {
return <p>hello world</p>
}
`,
'next.config.js': `
const nextConfig = {
reactStrictMode: true,
}
module.exports = nextConfig
`,
},
},
({ next }) => {
it('should output config file change', async () => {
await check(
async () => next.cliOutput,
/compiled client and server successfully/
)
await next.patchFile(
'next.config.js',
`
const nextConfig = {
reactStrictMode: true,
async redirects() {
return [
{
source: '/about',
destination: '/',
permanent: true,
},
]
},
}
module.exports = nextConfig`
)
await check(
async () => next.cliOutput,
/Found a change in next\.config\.js\. Restarting the server to apply the changes\.\.\./
)
await check(() => next.fetch('/about').then((res) => res.status), 200)
})
}
)