@sentry/wizard
Version:
Sentry wizard helping you to configure your project
158 lines (141 loc) • 5.45 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");
const vitest_1 = require("vitest");
(0, vitest_1.describe)('initializeSentryOnEntryClient', () => {
(0, vitest_1.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,
logs: true,
};
const result = (0, sdk_setup_1.updateEntryClientMod)(originalEntryClientMod, dsn, selectedFeatures);
(0, vitest_1.expect)(result.generate().code).toMatchInlineSnapshot(`
"import { useEffect,} from "react";
import {
useLocation,
useMatches,
} from "@remix-run/react";
import { init, replayIntegration, browserTracingIntegration,} from "@sentry/remix";
init({
dsn: "https://sentry.io/123",
tracesSampleRate: 1,
enableLogs: true,
integrations: [browserTracingIntegration({
useEffect,
useLocation,
useMatches
}), replayIntegration({
maskAllText: true,
blockAllMedia: true
})],
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1
})"
`);
});
(0, vitest_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,
logs: false,
};
const result = (0, sdk_setup_1.updateEntryClientMod)(originalEntryClientMod, dsn, selectedFeatures);
(0, vitest_1.expect)(result.generate().code).toMatchInlineSnapshot(`
"import { init, replayIntegration,} from "@sentry/remix";
init({
dsn: "https://sentry.io/123",
integrations: [replayIntegration({
maskAllText: true,
blockAllMedia: true
})],
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1
})"
`);
});
(0, vitest_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,
logs: false,
};
const result = (0, sdk_setup_1.updateEntryClientMod)(originalEntryClientMod, dsn, selectedFeatures);
(0, vitest_1.expect)(result.generate().code).toMatchInlineSnapshot(`
"import { useEffect,} from "react";
import {
useLocation,
useMatches,
} from "@remix-run/react";
import { init, browserTracingIntegration,} from "@sentry/remix";
init({
dsn: "https://sentry.io/123",
tracesSampleRate: 1,
integrations: [browserTracingIntegration({
useEffect,
useLocation,
useMatches
})]
})"
`);
});
(0, vitest_1.it)('should initialize Sentry on client entry with only logs enabled', () => {
// Empty entry.client.tsx file for testing
const originalEntryClientMod = (0, magicast_1.parseModule)('');
const dsn = 'https://sentry.io/123';
const selectedFeatures = {
performance: false,
replay: false,
logs: true,
};
const result = (0, sdk_setup_1.updateEntryClientMod)(originalEntryClientMod, dsn, selectedFeatures);
(0, vitest_1.expect)(result.generate().code).toMatchInlineSnapshot(`
"import { init,} from "@sentry/remix";
init({
dsn: "https://sentry.io/123",
enableLogs: true
})"
`);
});
(0, vitest_1.it)('should initialize Sentry on client entry with performance and logs 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: false,
logs: true,
};
const result = (0, sdk_setup_1.updateEntryClientMod)(originalEntryClientMod, dsn, selectedFeatures);
(0, vitest_1.expect)(result.generate().code).toMatchInlineSnapshot(`
"import { useEffect,} from "react";
import {
useLocation,
useMatches,
} from "@remix-run/react";
import { init, browserTracingIntegration,} from "@sentry/remix";
init({
dsn: "https://sentry.io/123",
tracesSampleRate: 1,
enableLogs: true,
integrations: [browserTracingIntegration({
useEffect,
useLocation,
useMatches
})]
})"
`);
});
});
//# sourceMappingURL=client-entry.test.js.map