Skip to content

Commit e0282b6

Browse files
authored
test(remix): Stop relying on node-integration-tests in remix (#14253)
Oops, #14245 broke our remix integration tests. Instead of re-exporting this from a path (which is not resolved nicely etc. and not reflected by our dependency graph) we can just inline the two methods we need here, they are not too complicated.
1 parent 9e37c31 commit e0282b6

File tree

1 file changed

+31
-3
lines changed
  • packages/remix/test/integration/test/server/utils

1 file changed

+31
-3
lines changed

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as path from 'path';
44
import { createRequestHandler } from '@remix-run/express';
55
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
66
import * as Sentry from '@sentry/node';
7-
import type { EnvelopeItemType } from '@sentry/types';
7+
import type { EnvelopeItemType, Event, TransactionEvent } from '@sentry/types';
88
import { logger } from '@sentry/utils';
99
import type { AxiosRequestConfig } from 'axios';
1010
import axios from 'axios';
@@ -14,8 +14,6 @@ import type { HttpTerminator } from 'http-terminator';
1414
import { createHttpTerminator } from 'http-terminator';
1515
import nock from 'nock';
1616

17-
export * from '../../../../../../../dev-packages/node-integration-tests/utils';
18-
1917
type DataCollectorOptions = {
2018
// Optional custom URL
2119
url?: string;
@@ -284,3 +282,33 @@ export class RemixTestEnv extends TestEnv {
284282
const parseEnvelope = (body: string): Array<Record<string, unknown>> => {
285283
return body.split('\n').map(e => JSON.parse(e));
286284
};
285+
286+
/**
287+
* Asserts against a Sentry Event ignoring non-deterministic properties
288+
*
289+
* @param {Record<string, unknown>} actual
290+
* @param {Record<string, unknown>} expected
291+
*/
292+
export const assertSentryEvent = (actual: Event, expected: Record<string, unknown>): void => {
293+
expect(actual).toMatchObject({
294+
event_id: expect.any(String),
295+
...expected,
296+
});
297+
};
298+
299+
/**
300+
* Asserts against a Sentry Transaction ignoring non-deterministic properties
301+
*
302+
* @param {Record<string, unknown>} actual
303+
* @param {Record<string, unknown>} expected
304+
*/
305+
export const assertSentryTransaction = (actual: TransactionEvent, expected: Record<string, unknown>): void => {
306+
expect(actual).toMatchObject({
307+
event_id: expect.any(String),
308+
timestamp: expect.anything(),
309+
start_timestamp: expect.anything(),
310+
spans: expect.any(Array),
311+
type: 'transaction',
312+
...expected,
313+
});
314+
};

0 commit comments

Comments
 (0)