rsnext/test/unit/cli.test.ts
Shu Ding c11bce5989
Opt-into worker mode when appDir is enabled (#47857)
This unblocks further optimization opportunities as well as fixes for
systematic problems such as NEXT-227. After this PR, only production
mode of non-app projects will be running on the legacy main process
mode.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-04-11 22:26:49 +02:00

36 lines
1.1 KiB
TypeScript

import { nextStart } from 'next/dist/cli/next-start'
import httpMock, { Server } from 'http'
// Prevents bin from running
jest.mock('next/dist/bin/next', () => ({}))
jest.mock('next/dist/lib/get-project-dir', () => ({ getProjectDir: () => '' }))
jest.mock('http')
// this test is unreliable as nextStart is not synchronous and the
// server could be created at any point
describe.skip('start', () => {
test('--keepAliveTimeout changes server.keepAliveTimeout when passed', () => {
const server = {
on: () => {},
listen: () => {},
} as any as Server
;(httpMock as any).createServer.mockReturnValue(server)
expect(server.keepAliveTimeout).toBe(undefined)
nextStart(['--keepAliveTimeout', '1234'])
expect(server.keepAliveTimeout).toBe(1234)
})
test("--keepAliveTimeout doesn't change server.keepAliveTimeout when not passed", () => {
const server = {
on: () => {},
listen: () => {},
} as any as Server
;(httpMock as any).createServer.mockReturnValue(server)
expect(server.keepAliveTimeout).toBe(undefined)
nextStart([])
expect(server.keepAliveTimeout).toBe(undefined)
})
})