| 22 | |
| 23 | const runTests = (isDev: boolean) => { |
| 24 | const getData = async () => { |
| 25 | if (isDev) { |
| 26 | appPort = await findPort() |
| 27 | app = await launchApp(appDir, appPort) |
| 28 | } else { |
| 29 | const { code } = await nextBuild(appDir) |
| 30 | if (code !== 0) throw new Error(`build faild, exit code: ${code}`) |
| 31 | appPort = await findPort() |
| 32 | app = await nextStart(appDir, appPort) |
| 33 | } |
| 34 | const html = await renderViaHTTP(appPort, '/') |
| 35 | await killApp(app) |
| 36 | const $ = cheerio.load(html) |
| 37 | return JSON.parse($('#__NEXT_DATA__').text()) |
| 38 | } |
| 39 | |
| 40 | it('should not have gip or appGip in NEXT_DATA for page without getInitialProps', async () => { |
| 41 | const data = await getData() |