Skip to content

Commit 7420db4

Browse files
committed
Rm fastify-remix from integrtions tests
1 parent 5245b4f commit 7420db4

File tree

5 files changed

+25
-49
lines changed

5 files changed

+25
-49
lines changed

packages/remix/test/integration/package.json

-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@
77
"start": "remix-serve build"
88
},
99
"dependencies": {
10-
"@fastify/formbody": "^7.4.0",
11-
"@mcansh/remix-fastify": "^3.2.2",
1210
"@remix-run/express": "1.17.0",
1311
"@remix-run/node": "1.17.0",
1412
"@remix-run/react": "1.17.0",
1513
"@remix-run/serve": "1.17.0",
1614
"@sentry/remix": "file:../..",
1715
"express": "^4.19.2",
18-
"fastify": "^4.26.2",
1916
"react": "^17.0.2",
2017
"react-dom": "^17.0.2"
2118
},

packages/remix/test/integration/test/server/action.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Adapter, RemixTestEnv, assertSentryEvent, assertSentryTransaction } from './utils/helpers';
1+
import { RemixTestEnv, assertSentryEvent, assertSentryTransaction } from './utils/helpers';
22

33
const useV2 = process.env.REMIX_VERSION === '2';
44

55
jest.spyOn(console, 'error').mockImplementation();
66

77
// Repeat tests for each adapter
8-
describe.each([Adapter.Builtin, Adapter.Express, Adapter.Fastify])('Remix API Actions with adapter = %s', adapter => {
8+
describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', adapter => {
99
it('correctly instruments a parameterized Remix API action', async () => {
1010
const env = await RemixTestEnv.init(adapter);
1111
const url = `${env.url}/action-json-response/123123`;

packages/remix/test/integration/test/server/loader.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Event } from '@sentry/types';
2-
import { Adapter, RemixTestEnv, assertSentryEvent, assertSentryTransaction } from './utils/helpers';
2+
import { RemixTestEnv, assertSentryEvent, assertSentryTransaction } from './utils/helpers';
33

44
const useV2 = process.env.REMIX_VERSION === '2';
55

66
jest.spyOn(console, 'error').mockImplementation();
77

88
// Repeat tests for each adapter
9-
describe.each([Adapter.Builtin, Adapter.Express, Adapter.Fastify])('Remix API Loaders with adapter = %s', adapter => {
9+
describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', adapter => {
1010
it('reports an error thrown from the loader', async () => {
1111
const env = await RemixTestEnv.init(adapter);
1212
const url = `${env.url}/loader-json-response/-2`;

packages/remix/test/integration/test/server/ssr.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Adapter, RemixTestEnv, assertSentryEvent, assertSentryTransaction } from './utils/helpers';
1+
import { RemixTestEnv, assertSentryEvent, assertSentryTransaction } from './utils/helpers';
22

33
const useV2 = process.env.REMIX_VERSION === '2';
44

55
describe('Server Side Rendering', () => {
66
it('correctly reports a server side rendering error', async () => {
7-
const env = await RemixTestEnv.init(Adapter.Builtin);
7+
const env = await RemixTestEnv.init('builtin');
88
const url = `${env.url}/ssr-error`;
99
const envelopes = await env.getMultipleEnvelopeRequest({ url, count: 2, envelopeType: ['transaction', 'event'] });
1010
const [transaction] = envelopes.filter(envelope => envelope[1].type === 'transaction');
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,33 @@
11
import * as http from 'http';
22
import { AddressInfo } from 'net';
3-
import { createRequestHandler as createFastifyRequestHandler } from '@mcansh/remix-fastify';
4-
import { createRequestHandler as createExpressRequestHandler } from '@remix-run/express';
5-
import { wrapExpressCreateRequestHandler, wrapFastifyCreateRequestHandler } from '@sentry/remix';
3+
import { createRequestHandler } from '@remix-run/express';
4+
import { wrapExpressCreateRequestHandler } from '@sentry/remix';
65
import express from 'express';
7-
import fastify from 'fastify';
8-
import formBody from '@fastify/formbody'
9-
106
import { TestEnv } from '../../../../../../../dev-packages/node-integration-tests/utils';
117

128
export * from '../../../../../../../dev-packages/node-integration-tests/utils';
139

14-
export const enum Adapter {
15-
Builtin = 'builtin',
16-
Express = 'express',
17-
Fastify = 'fastify',
18-
}
19-
20-
const adapters = {
21-
[Adapter.Builtin]: createExpressRequestHandler,
22-
[Adapter.Express]: wrapExpressCreateRequestHandler(createExpressRequestHandler),
23-
[Adapter.Fastify]: wrapFastifyCreateRequestHandler(createFastifyRequestHandler),
24-
};
25-
26-
const runExpressApp = (adapter: Adapter.Builtin | Adapter.Express): Promise<http.Server> => new Promise(
27-
res => {
28-
const app = express();
29-
app.all('*', adapters[adapter]({ build: require('../../../build') }));
30-
res(app.listen(0));
31-
}
32-
)
33-
34-
const runFastifyApp = (): Promise<http.Server> => new Promise(res => {
35-
const app = fastify();
36-
app.register(formBody);
37-
// @ts-ignore
38-
app.all('*', adapters[Adapter.Fastify]({ build: require('../../../build') }));
39-
app.listen({port: 0}, (_err, _addr) => {
40-
res(app.server)
41-
});
42-
})
43-
4410
export class RemixTestEnv extends TestEnv {
4511
private constructor(public readonly server: http.Server, public readonly url: string) {
4612
super(server, url);
4713
}
4814

49-
public static async init(adapter: Adapter): Promise<RemixTestEnv> {
50-
const srv = adapter === Adapter.Fastify ? await runFastifyApp() : await runExpressApp(adapter);
51-
const port = (srv.address() as AddressInfo).port
52-
return new RemixTestEnv(srv, `http://localhost:${port}`);
15+
public static async init(adapter: string = 'builtin'): Promise<RemixTestEnv> {
16+
const requestHandlerFactory =
17+
adapter === 'express' ? wrapExpressCreateRequestHandler(createRequestHandler) : createRequestHandler;
18+
19+
let serverPort;
20+
const server = await new Promise<http.Server>(resolve => {
21+
const app = express();
22+
23+
app.all('*', requestHandlerFactory({ build: require('../../../build') }));
24+
25+
const server = app.listen(0, () => {
26+
serverPort = (server.address() as AddressInfo).port;
27+
resolve(server);
28+
});
29+
});
30+
31+
return new RemixTestEnv(server, `http://localhost:${serverPort}`);
5332
}
5433
}

0 commit comments

Comments
 (0)