rsnext/test/integration/empty-project/test/index.test.js
Tim Neutkens 8122d82130 Handle empty directory (#7876)
* Add test for empty directory

* Fix test re-runs

* Handle empty `pages/` directory
2019-07-10 11:45:53 -04:00

28 lines
828 B
JavaScript

/* eslint-env jest */
/* global jasmine */
import { join } from 'path'
import fs from 'fs'
import { fetchViaHTTP, findPort, launchApp, killApp } from 'next-test-utils'
const context = {}
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 5
describe('Empty Project', () => {
beforeAll(async () => {
fs.unlinkSync(join(__dirname, '..', 'pages', '.gitkeep'))
context.appPort = await findPort()
context.server = await launchApp(join(__dirname, '../'), context.appPort)
})
const fetch = (p, q) => fetchViaHTTP(context.appPort, p, q, { timeout: 5000 })
it('Should not time out and return 404', async () => {
const res = await fetch('/')
expect(res.status).toBe(404)
})
afterAll(() => {
killApp(context.server)
fs.closeSync(fs.openSync(join(__dirname, '..', 'pages', '.gitkeep'), 'w'))
})
})