rsnext/test/integration/invalid-multi-match/test/index.test.js
2020-05-27 17:51:11 -04:00

59 lines
1.2 KiB
JavaScript

/* eslint-env jest */
import { join } from 'path'
import {
launchApp,
killApp,
findPort,
nextBuild,
nextStart,
renderViaHTTP,
} from 'next-test-utils'
jest.setTimeout(1000 * 60 * 2)
let appDir = join(__dirname, '..')
let stderr = ''
let appPort
let app
const runTests = () => {
it('should show error for invalid mulit-match', async () => {
await renderViaHTTP(appPort, '/random')
expect(stderr).toContain(
'To use a multi-match in the destination you must add'
)
expect(stderr).toContain(
'https://err.sh/vercel/next.js/invalid-multi-match'
)
})
}
describe('Custom routes invalid multi-match', () => {
describe('dev mode', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr: (msg) => {
stderr += msg
},
})
})
afterAll(() => killApp(app))
runTests(true)
})
describe('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort, {
onStderr: (msg) => {
stderr += msg
},
})
})
afterAll(() => killApp(app))
runTests()
})
})