2023-07-29 22:52:19 +02:00
|
|
|
// @cspotcode/zx is zx in CommonJS
|
|
|
|
import {$, cd, path, ProcessPromise} from '@cspotcode/zx'
|
|
|
|
import {testServerAndPage} from '../../utils/testUtils'
|
|
|
|
|
|
|
|
const PATH_TO_PACKAGE = path.join(__dirname, `./package`)
|
|
|
|
|
|
|
|
describe(`next`, () => {
|
|
|
|
describe(`build`, () => {
|
|
|
|
test(`command runs without error`, async () => {
|
|
|
|
cd(PATH_TO_PACKAGE)
|
|
|
|
const {exitCode} = await $`npm run build`
|
|
|
|
// at this point, the build should have succeeded
|
|
|
|
expect(exitCode).toEqual(0)
|
|
|
|
})
|
|
|
|
|
|
|
|
describe(`next start`, () => {
|
|
|
|
testServerAndPage({
|
|
|
|
startServerOnPort: (port: number) => {
|
|
|
|
cd(PATH_TO_PACKAGE)
|
|
|
|
|
|
|
|
return $`npm run start -- --port ${port}`
|
|
|
|
},
|
|
|
|
|
2023-07-30 15:41:09 +02:00
|
|
|
checkServerStdoutToSeeIfItsReady: (chunk) =>
|
|
|
|
chunk.includes('started server'),
|
2023-07-29 22:52:19 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
// this test is not ready yet, so we'll skip it
|
|
|
|
describe(`$ next dev`, () => {
|
|
|
|
testServerAndPage({
|
|
|
|
startServerOnPort: (port: number) => {
|
|
|
|
cd(PATH_TO_PACKAGE)
|
|
|
|
|
|
|
|
return $`npm run dev -- --port ${port}`
|
|
|
|
},
|
2023-07-30 15:41:09 +02:00
|
|
|
checkServerStdoutToSeeIfItsReady: (chunk) =>
|
|
|
|
chunk.includes('compiled client and server successfully'),
|
2023-07-29 22:52:19 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|