From a0eaf8c87226624cd5abf3b154c52076aa90c502 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 13 Nov 2024 11:15:07 +0100 Subject: [PATCH 1/2] test(remix): Stop relying on node-integration-tests in remix 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. --- .../integration/test/server/utils/helpers.ts | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/remix/test/integration/test/server/utils/helpers.ts b/packages/remix/test/integration/test/server/utils/helpers.ts index 981be12f314a..6ae244caa263 100644 --- a/packages/remix/test/integration/test/server/utils/helpers.ts +++ b/packages/remix/test/integration/test/server/utils/helpers.ts @@ -4,7 +4,7 @@ import * as path from 'path'; import { createRequestHandler } from '@remix-run/express'; /* eslint-disable @typescript-eslint/no-unsafe-member-access */ import * as Sentry from '@sentry/node'; -import type { EnvelopeItemType } from '@sentry/types'; +import type { EnvelopeItemType, TransactionEvent, Event } from '@sentry/types'; import { logger } from '@sentry/utils'; import type { AxiosRequestConfig } from 'axios'; import axios from 'axios'; @@ -14,8 +14,6 @@ import type { HttpTerminator } from 'http-terminator'; import { createHttpTerminator } from 'http-terminator'; import nock from 'nock'; -export * from '../../../../../../../dev-packages/node-integration-tests/utils'; - type DataCollectorOptions = { // Optional custom URL url?: string; @@ -284,3 +282,34 @@ export class RemixTestEnv extends TestEnv { const parseEnvelope = (body: string): Array> => { return body.split('\n').map(e => JSON.parse(e)); }; + + +/** + * Asserts against a Sentry Event ignoring non-deterministic properties + * + * @param {Record} actual + * @param {Record} expected + */ +export const assertSentryEvent = (actual: Event, expected: Record): void => { + expect(actual).toMatchObject({ + event_id: expect.any(String), + ...expected, + }); +}; + +/** + * Asserts against a Sentry Transaction ignoring non-deterministic properties + * + * @param {Record} actual + * @param {Record} expected + */ +export const assertSentryTransaction = (actual: TransactionEvent, expected: Record): void => { + expect(actual).toMatchObject({ + event_id: expect.any(String), + timestamp: expect.anything(), + start_timestamp: expect.anything(), + spans: expect.any(Array), + type: 'transaction', + ...expected, + }); +}; From ab4f6e5b8b7a42f4450f031febee328664a84acd Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 13 Nov 2024 11:37:24 +0100 Subject: [PATCH 2/2] formatting --- packages/remix/test/integration/test/server/utils/helpers.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/remix/test/integration/test/server/utils/helpers.ts b/packages/remix/test/integration/test/server/utils/helpers.ts index 6ae244caa263..909d8d1671ae 100644 --- a/packages/remix/test/integration/test/server/utils/helpers.ts +++ b/packages/remix/test/integration/test/server/utils/helpers.ts @@ -4,7 +4,7 @@ import * as path from 'path'; import { createRequestHandler } from '@remix-run/express'; /* eslint-disable @typescript-eslint/no-unsafe-member-access */ import * as Sentry from '@sentry/node'; -import type { EnvelopeItemType, TransactionEvent, Event } from '@sentry/types'; +import type { EnvelopeItemType, Event, TransactionEvent } from '@sentry/types'; import { logger } from '@sentry/utils'; import type { AxiosRequestConfig } from 'axios'; import axios from 'axios'; @@ -283,7 +283,6 @@ const parseEnvelope = (body: string): Array> => { return body.split('\n').map(e => JSON.parse(e)); }; - /** * Asserts against a Sentry Event ignoring non-deterministic properties *