Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clean up
  • Loading branch information
onurtemizkan committed Jan 25, 2023
commit add1f41b14c59256c8bee4117467124f095d7ec8
31 changes: 30 additions & 1 deletion packages/nextjs/test/integration/test/server/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,36 @@ import { getPortPromise } from 'portfinder';
import { TestEnv } from '../../../../../../node-integration-tests/utils';
import * as http from 'http';
import * as path from 'path';
import { createNextServer, startServer } from '../../utils/common';
import { createServer, Server } from 'http';
import { parse } from 'url';
import next from 'next';

// Type not exported from NextJS
// @ts-ignore
export const createNextServer = async config => {
const app = next(config);
const handle = app.getRequestHandler();
await app.prepare();

return createServer((req, res) => {
const { url } = req;

if (!url) {
throw new Error('No url');
}

handle(req, res, parse(url, true));
});
};

export const startServer = async (server: Server, port: string | number) => {
return new Promise(resolve => {
server.listen(port || 0, () => {
const url = `http://localhost:${port}`;
resolve({ server, url });
});
});
};

export class NextTestEnv extends TestEnv {
private constructor(public readonly server: http.Server, public readonly url: string) {
Expand Down
63 changes: 0 additions & 63 deletions packages/nextjs/test/integration/test/utils/common.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/nextjs/test/integration/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.json",
"extends": "../../tsconfig.test.json",

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

Expand Down