UNPKG

@sentry/wizard

Version:

Sentry wizard helping you to configure your project

399 lines (349 loc) 17.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const templates_1 = require("../../src/nuxt/templates"); vitest_1.vi.mock('../../src/utils/clack/mcp-config', () => ({ offerProjectScopedMcpConfig: vitest_1.vi.fn().mockResolvedValue(undefined), })); (0, vitest_1.describe)('Nuxt code templates', () => { (0, vitest_1.describe)('getDefaultNuxtConfig', () => { (0, vitest_1.it)('returns a default nuxt config', () => { (0, vitest_1.expect)((0, templates_1.getDefaultNuxtConfig)()).toMatchInlineSnapshot(` "// https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ compatibilityDate: '2024-04-03', devtools: { enabled: true } }) " `); }); }); (0, vitest_1.describe)('getSentryConfigContents', () => { (0, vitest_1.describe)('client config', () => { (0, vitest_1.it)('generates Sentry config with all features enabled', () => { const template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'client', { performance: true, replay: true, logs: true, }); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` "import * as Sentry from "@sentry/nuxt"; Sentry.init({ // If set up, you can use your runtime config here // dsn: useRuntimeConfig().public.sentry.dsn, dsn: "https://sentry.io/123", // We recommend adjusting this value in production, or using tracesSampler // for finer control tracesSampleRate: 1.0, // This sets the sample rate to be 10%. You may want this to be 100% while // in development and sample at a lower rate in production replaysSessionSampleRate: 0.1, // If the entire session is not sampled, use the below sample rate to sample // sessions when an error occurs. replaysOnErrorSampleRate: 1.0, // If you don't want to use Session Replay, just remove the line below: integrations: [Sentry.replayIntegration()], // Enable logs to be sent to Sentry enableLogs: true, // Enable sending of user PII (Personally Identifiable Information) // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii sendDefaultPii: true, // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, }); " `); }); (0, vitest_1.it)('generates Sentry config with performance monitoring disabled', () => { const template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'client', { performance: false, replay: true, logs: true, }); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` "import * as Sentry from "@sentry/nuxt"; Sentry.init({ // If set up, you can use your runtime config here // dsn: useRuntimeConfig().public.sentry.dsn, dsn: "https://sentry.io/123", // This sets the sample rate to be 10%. You may want this to be 100% while // in development and sample at a lower rate in production replaysSessionSampleRate: 0.1, // If the entire session is not sampled, use the below sample rate to sample // sessions when an error occurs. replaysOnErrorSampleRate: 1.0, // If you don't want to use Session Replay, just remove the line below: integrations: [Sentry.replayIntegration()], // Enable logs to be sent to Sentry enableLogs: true, // Enable sending of user PII (Personally Identifiable Information) // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii sendDefaultPii: true, // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, }); " `); }); (0, vitest_1.it)('generates Sentry config with session replay disabled', () => { const template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'client', { performance: true, replay: false, logs: true, }); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` "import * as Sentry from "@sentry/nuxt"; Sentry.init({ // If set up, you can use your runtime config here // dsn: useRuntimeConfig().public.sentry.dsn, dsn: "https://sentry.io/123", // We recommend adjusting this value in production, or using tracesSampler // for finer control tracesSampleRate: 1.0, // Enable logs to be sent to Sentry enableLogs: true, // Enable sending of user PII (Personally Identifiable Information) // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii sendDefaultPii: true, // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, }); " `); }); (0, vitest_1.it)('generates Sentry config with logs disabled', () => { const template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'client', { performance: true, replay: true, logs: false, }); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` "import * as Sentry from "@sentry/nuxt"; Sentry.init({ // If set up, you can use your runtime config here // dsn: useRuntimeConfig().public.sentry.dsn, dsn: "https://sentry.io/123", // We recommend adjusting this value in production, or using tracesSampler // for finer control tracesSampleRate: 1.0, // This sets the sample rate to be 10%. You may want this to be 100% while // in development and sample at a lower rate in production replaysSessionSampleRate: 0.1, // If the entire session is not sampled, use the below sample rate to sample // sessions when an error occurs. replaysOnErrorSampleRate: 1.0, // If you don't want to use Session Replay, just remove the line below: integrations: [Sentry.replayIntegration()], // Enable sending of user PII (Personally Identifiable Information) // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii sendDefaultPii: true, // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, }); " `); }); (0, vitest_1.it)('generates Sentry config with performance monitoring and session replay disabled', () => { const template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'client', { performance: false, replay: false, logs: true, }); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` "import * as Sentry from "@sentry/nuxt"; Sentry.init({ // If set up, you can use your runtime config here // dsn: useRuntimeConfig().public.sentry.dsn, dsn: "https://sentry.io/123", // Enable logs to be sent to Sentry enableLogs: true, // Enable sending of user PII (Personally Identifiable Information) // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii sendDefaultPii: true, // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, }); " `); }); (0, vitest_1.it)('generates Sentry config with all features disabled', () => { const template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'client', { performance: false, replay: false, logs: false, }); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` "import * as Sentry from "@sentry/nuxt"; Sentry.init({ // If set up, you can use your runtime config here // dsn: useRuntimeConfig().public.sentry.dsn, dsn: "https://sentry.io/123", // Enable sending of user PII (Personally Identifiable Information) // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii sendDefaultPii: true, // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, }); " `); }); }); (0, vitest_1.describe)('server config', () => { (0, vitest_1.it)('generates Sentry config with all features enabled', () => { const template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'server', { performance: true, replay: true, logs: true, }); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` "import * as Sentry from "@sentry/nuxt"; Sentry.init({ dsn: "https://sentry.io/123", // We recommend adjusting this value in production, or using tracesSampler // for finer control tracesSampleRate: 1.0, // Enable logs to be sent to Sentry enableLogs: true, // Enable sending of user PII (Personally Identifiable Information) // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii sendDefaultPii: true, // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, }); " `); }); (0, vitest_1.it)('generates Sentry config with performance monitoring disabled', () => { const template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'server', { performance: false, replay: true, logs: true, }); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` "import * as Sentry from "@sentry/nuxt"; Sentry.init({ dsn: "https://sentry.io/123", // Enable logs to be sent to Sentry enableLogs: true, // Enable sending of user PII (Personally Identifiable Information) // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii sendDefaultPii: true, // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, }); " `); }); (0, vitest_1.it)('generates Sentry config with logs disabled', () => { const template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'server', { performance: true, replay: true, logs: false, }); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` "import * as Sentry from "@sentry/nuxt"; Sentry.init({ dsn: "https://sentry.io/123", // We recommend adjusting this value in production, or using tracesSampler // for finer control tracesSampleRate: 1.0, // Enable sending of user PII (Personally Identifiable Information) // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii sendDefaultPii: true, // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, }); " `); }); (0, vitest_1.it)('generates Sentry config with all features disabled', () => { const template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'server', { performance: false, replay: false, logs: false, }); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` "import * as Sentry from "@sentry/nuxt"; Sentry.init({ dsn: "https://sentry.io/123", // Enable sending of user PII (Personally Identifiable Information) // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii sendDefaultPii: true, // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, }); " `); }); }); }); (0, vitest_1.describe)('getNuxtModuleFallbackTemplate', () => { (0, vitest_1.it)('generates configuration options for the nuxt config', () => { const template = (0, templates_1.getNuxtModuleFallbackTemplate)({ org: 'my-org', project: 'my-project', url: 'https://sentry.io', selfHosted: false, }, false); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` " modules: ["@sentry/nuxt/module"], sentry: { org: "my-org", project: "my-project", sourcemaps: { // This will delete all .map files in the build output after uploading them to Sentry. Modify as needed. // For more information, see: https://docs.sentry.io/platforms/javascript/guides/nuxt/sourcemaps/ filesToDeleteAfterUpload: ['.*/**/*.map'] }, }, sourcemap: { client: "hidden" }," `); }); (0, vitest_1.it)('generates configuration options for the nuxt config with top level import', () => { const template = (0, templates_1.getNuxtModuleFallbackTemplate)({ org: 'my-org', project: 'my-project', url: 'https://sentry.io', selfHosted: false, }, true); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` " modules: ["@sentry/nuxt/module"], sentry: { org: "my-org", project: "my-project", sourcemaps: { // This will delete all .map files in the build output after uploading them to Sentry. Modify as needed. // For more information, see: https://docs.sentry.io/platforms/javascript/guides/nuxt/sourcemaps/ filesToDeleteAfterUpload: ['.*/**/*.map'] }, autoInjectServerSentry: "top-level-import", }, sourcemap: { client: "hidden" }," `); }); (0, vitest_1.it)('generates configuration options for the nuxt config with top level import and self-hosted url', () => { const template = (0, templates_1.getNuxtModuleFallbackTemplate)({ org: 'my-org', project: 'my-project', url: 'https://sentry.io', selfHosted: true, }, true); (0, vitest_1.expect)(template).toMatchInlineSnapshot(` " modules: ["@sentry/nuxt/module"], sentry: { org: "my-org", project: "my-project", url: "https://sentry.io", sourcemaps: { // This will delete all .map files in the build output after uploading them to Sentry. Modify as needed. // For more information, see: https://docs.sentry.io/platforms/javascript/guides/nuxt/sourcemaps/ filesToDeleteAfterUpload: ['.*/**/*.map'] }, autoInjectServerSentry: "top-level-import", }, sourcemap: { client: "hidden" }," `); }); }); }); //# sourceMappingURL=templates.test.js.map