Skip to content

Commit a065c41

Browse files
committed
Update Remix tests to the new structure.
1 parent c4eac20 commit a065c41

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
1313
it('correctly instruments a parameterized Remix API action', async () => {
1414
const config = await runServer(adapter);
1515
const url = `${config.url}/action-json-response/123123`;
16-
const envelope = await getEnvelopeRequest({ ...config, url }, { method: 'post' });
16+
const envelope = await getEnvelopeRequest({ ...config, url }, { method: 'post', envelopeType: 'transaction' });
1717
const transaction = envelope[2];
1818

1919
assertSentryTransaction(transaction, {
@@ -43,7 +43,10 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
4343
const config = await runServer(adapter);
4444
const url = `${config.url}/action-json-response/-1`;
4545

46-
const [transaction, event] = await getMultipleEnvelopeRequest({ ...config, url }, { count: 2, method: 'post' });
46+
const [transaction, event] = await getMultipleEnvelopeRequest(
47+
{ ...config, url },
48+
{ count: 2, method: 'post', envelopeType: ['transaction', 'event'] },
49+
);
4750

4851
assertSentryTransaction(transaction[2], {
4952
contexts: {
@@ -82,7 +85,7 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
8285

8386
const [transaction_1, event, transaction_2] = await getMultipleEnvelopeRequest(
8487
{ ...config, url },
85-
{ count: 3, method: 'post' },
88+
{ count: 3, method: 'post', envelopeType: ['transaction', 'event'] },
8689
);
8790

8891
assertSentryTransaction(transaction_1[2], {

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
1515
const config = await runServer(adapter);
1616
const url = `${config.url}/loader-json-response/-2`;
1717

18-
const envelopes = await getMultipleEnvelopeRequest({ ...config, url }, { count: 2 });
18+
const envelopes = await getMultipleEnvelopeRequest(
19+
{ ...config, url },
20+
{ count: 2, envelopeType: ['transaction', 'event'] },
21+
);
1922

2023
const event = envelopes[0][2].type === 'transaction' ? envelopes[1][2] : envelopes[0][2];
2124
const transaction = envelopes[0][2].type === 'transaction' ? envelopes[0][2] : envelopes[1][2];
@@ -54,7 +57,7 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
5457
it('correctly instruments a parameterized Remix API loader', async () => {
5558
const config = await runServer(adapter);
5659
const url = `${config.url}/loader-json-response/123123`;
57-
const envelope = await getEnvelopeRequest({ ...config, url });
60+
const envelope = await getEnvelopeRequest({ ...config, url }, { envelopeType: 'transaction' });
5861
const transaction = envelope[2];
5962

6063
assertSentryTransaction(transaction, {
@@ -83,7 +86,10 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
8386
const config = await runServer(adapter);
8487
const url = `${config.url}/loader-json-response/-1`;
8588

86-
const [transaction_1, event, transaction_2] = await getMultipleEnvelopeRequest({ ...config, url }, { count: 3 });
89+
const [transaction_1, event, transaction_2] = await getMultipleEnvelopeRequest(
90+
{ ...config, url },
91+
{ count: 3, envelopeType: ['transaction', 'event'] },
92+
);
8793

8894
assertSentryTransaction(transaction_1[2], {
8995
contexts: {
@@ -138,16 +144,15 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
138144
});
139145

140146
it('makes sure scope does not bleed between requests', async () => {
141-
const { url, server, scope } = await runServer(adapter);
147+
const { url, server } = await runServer(adapter);
142148

143149
const envelopes = await Promise.all([
144-
getEnvelopeRequest({ url: `${url}/scope-bleed/1`, server, scope }, { endServer: false }),
145-
getEnvelopeRequest({ url: `${url}/scope-bleed/2`, server, scope }, { endServer: false }),
146-
getEnvelopeRequest({ url: `${url}/scope-bleed/3`, server, scope }, { endServer: false }),
147-
getEnvelopeRequest({ url: `${url}/scope-bleed/4`, server, scope }, { endServer: false }),
150+
getEnvelopeRequest({ url: `${url}/scope-bleed/1`, server }, { endServer: false, envelopeType: 'transaction' }),
151+
getEnvelopeRequest({ url: `${url}/scope-bleed/2`, server }, { endServer: false, envelopeType: 'transaction' }),
152+
getEnvelopeRequest({ url: `${url}/scope-bleed/3`, server }, { endServer: false, envelopeType: 'transaction' }),
153+
getEnvelopeRequest({ url: `${url}/scope-bleed/4`, server }, { endServer: false, envelopeType: 'transaction' }),
148154
]);
149155

150-
scope.persist(false);
151156
await new Promise(resolve => server.close(resolve));
152157

153158
envelopes.forEach(envelope => {

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { createRequestHandler } from '@remix-run/express';
33
import { getPortPromise } from 'portfinder';
44
import { wrapExpressCreateRequestHandler } from '@sentry/remix';
55
import type { TestServerConfig } from '../../../../../../node-integration-tests/utils';
6-
import nock from 'nock';
76
import * as http from 'http';
87

98
export * from '../../../../../../node-integration-tests/utils';
@@ -18,21 +17,18 @@ export async function runServer(adapter: string = 'builtin'): Promise<TestServer
1817

1918
const port = await getPortPromise();
2019

21-
const { server, scope } = await new Promise<{ server: http.Server; scope: nock.Scope }>(resolve => {
20+
const server = await new Promise<http.Server>(resolve => {
2221
const app = express();
2322

2423
app.all('*', requestHandlerFactory({ build: require('../../../build') }));
2524

2625
const server = app.listen(port, () => {
27-
const scope = nock('https://dsn.ingest.sentry.io').persist();
28-
29-
resolve({ server, scope });
26+
resolve(server);
3027
});
3128
});
3229

3330
return {
3431
url: `http://localhost:${port}`,
3532
server,
36-
scope,
3733
};
3834
}

0 commit comments

Comments
 (0)