Skip to content

Commit 8944a97

Browse files
committed
Exit the server after tests.
1 parent a8f9b8d commit 8944a97

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const baseConfig = require('../../jest.config.js');
22

33
module.exports = {
4-
globalSetup: '<rootDir>/test/server/utils/run-server.ts',
4+
globalSetup: '<rootDir>/test/server/utils/test-setup.ts',
5+
globalTeardown: '<rootDir>/test/server/utils/test-teardown.ts',
56
...baseConfig,
67
testMatch: ['**/*.test.ts'],
78
};
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
import express, { Express } from 'express';
1+
import express from 'express';
22
import { createRequestHandler } from '@remix-run/express';
3+
import { Server } from 'http';
4+
5+
declare global {
6+
var __REMIX_SERVER__: Server;
7+
}
38

49
/**
510
* Runs a test server
611
*/
7-
function runServer(testDir: string): void {
12+
function runServer(): void {
813
const app = express();
914

1015
app.all('*', createRequestHandler({ build: require('../../../build') }));
1116

12-
app.listen(3000);
13-
14-
// TODO: Finish app after tests
17+
globalThis.__REMIX_SERVER__ = app.listen(3000);
1518
}
1619

1720
export default runServer;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function exitServer(): void {
2+
globalThis.__REMIX_SERVER__.close();
3+
}
4+
5+
export default exitServer;

0 commit comments

Comments
 (0)