Skip to content

test(remix): Stop relying on node-integration-tests in remix #14253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions packages/remix/test/integration/test/server/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, Event, TransactionEvent } from '@sentry/types';
import { logger } from '@sentry/utils';
import type { AxiosRequestConfig } from 'axios';
import axios from 'axios';
Expand All @@ -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;
Expand Down Expand Up @@ -284,3 +282,33 @@ export class RemixTestEnv extends TestEnv {
const parseEnvelope = (body: string): Array<Record<string, unknown>> => {
return body.split('\n').map(e => JSON.parse(e));
};

/**
* Asserts against a Sentry Event ignoring non-deterministic properties
*
* @param {Record<string, unknown>} actual
* @param {Record<string, unknown>} expected
*/
export const assertSentryEvent = (actual: Event, expected: Record<string, unknown>): void => {
expect(actual).toMatchObject({
event_id: expect.any(String),
...expected,
});
};

/**
* Asserts against a Sentry Transaction ignoring non-deterministic properties
*
* @param {Record<string, unknown>} actual
* @param {Record<string, unknown>} expected
*/
export const assertSentryTransaction = (actual: TransactionEvent, expected: Record<string, unknown>): void => {
expect(actual).toMatchObject({
event_id: expect.any(String),
timestamp: expect.anything(),
start_timestamp: expect.anything(),
spans: expect.any(Array),
type: 'transaction',
...expected,
});
};
Loading