Skip to content

Commit add1f41

Browse files
committed
Clean up
1 parent 94937c6 commit add1f41

File tree

3 files changed

+31
-65
lines changed

3 files changed

+31
-65
lines changed

packages/nextjs/test/integration/test/server/utils/helpers.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,36 @@ import { getPortPromise } from 'portfinder';
22
import { TestEnv } from '../../../../../../node-integration-tests/utils';
33
import * as http from 'http';
44
import * as path from 'path';
5-
import { createNextServer, startServer } from '../../utils/common';
5+
import { createServer, Server } from 'http';
6+
import { parse } from 'url';
7+
import next from 'next';
8+
9+
// Type not exported from NextJS
10+
// @ts-ignore
11+
export const createNextServer = async config => {
12+
const app = next(config);
13+
const handle = app.getRequestHandler();
14+
await app.prepare();
15+
16+
return createServer((req, res) => {
17+
const { url } = req;
18+
19+
if (!url) {
20+
throw new Error('No url');
21+
}
22+
23+
handle(req, res, parse(url, true));
24+
});
25+
};
26+
27+
export const startServer = async (server: Server, port: string | number) => {
28+
return new Promise(resolve => {
29+
server.listen(port || 0, () => {
30+
const url = `http://localhost:${port}`;
31+
resolve({ server, url });
32+
});
33+
});
34+
};
635

736
export class NextTestEnv extends TestEnv {
837
private constructor(public readonly server: http.Server, public readonly url: string) {

packages/nextjs/test/integration/test/utils/common.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

packages/nextjs/test/integration/tsconfig.test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "./tsconfig.json",
2+
"extends": "../../tsconfig.test.json",
33

44
"include": ["test/**/*"],
55

0 commit comments

Comments
 (0)