@sentry/wizard
Version:
Sentry wizard helping you to configure your project
101 lines (89 loc) • 3.37 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
const magicast_1 = require("magicast");
const sdk_setup_1 = require("../../src/remix/sdk-setup");
describe('initializeSentryOnEntryClient', () => {
it('should initialize Sentry on client entry with all features enabled', () => {
// Empty entry.client.tsx file for testing
const originalEntryClientMod = (0, magicast_1.parseModule)('');
const dsn = 'https://sentry.io/123';
const selectedFeatures = {
performance: true,
replay: true,
};
const result = (0, sdk_setup_1.updateEntryClientMod)(originalEntryClientMod, dsn, selectedFeatures);
expect(result.generate().code).toMatchInlineSnapshot(`
"import { useEffect,} from "react";
import {
useLocation,
useMatches,
} from "@remix-run/react";
import * as Sentry from "@sentry/remix";
Sentry.init({
dsn: "https://sentry.io/123",
tracesSampleRate: 1,
integrations: [Sentry.browserTracingIntegration({
useEffect,
useLocation,
useMatches
}), Sentry.replayIntegration({
maskAllText: true,
blockAllMedia: true
})],
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1
})"
`);
});
it('should initialize Sentry on client entry when performance disabled', () => {
// Empty entry.client.tsx file for testing
const originalEntryClientMod = (0, magicast_1.parseModule)('');
const dsn = 'https://sentry.io/123';
const selectedFeatures = {
performance: false,
replay: true,
};
const result = (0, sdk_setup_1.updateEntryClientMod)(originalEntryClientMod, dsn, selectedFeatures);
expect(result.generate().code).toMatchInlineSnapshot(`
"import * as Sentry from "@sentry/remix";
Sentry.init({
dsn: "https://sentry.io/123",
integrations: [Sentry.replayIntegration({
maskAllText: true,
blockAllMedia: true
})],
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1
})"
`);
});
it('should initialize Sentry on client entry when replay disabled', () => {
// Empty entry.client.tsx file for testing
const originalEntryClientMod = (0, magicast_1.parseModule)('');
const dsn = 'https://sentry.io/123';
const selectedFeatures = {
performance: true,
replay: false,
};
const result = (0, sdk_setup_1.updateEntryClientMod)(originalEntryClientMod, dsn, selectedFeatures);
expect(result.generate().code).toMatchInlineSnapshot(`
"import { useEffect,} from "react";
import {
useLocation,
useMatches,
} from "@remix-run/react";
import * as Sentry from "@sentry/remix";
Sentry.init({
dsn: "https://sentry.io/123",
tracesSampleRate: 1,
integrations: [Sentry.browserTracingIntegration({
useEffect,
useLocation,
useMatches
})]
})"
`);
});
});
//# sourceMappingURL=client-entry.test.js.map