@sentry/wizard
Version:
Sentry wizard helping you to configure your project
157 lines • 8.07 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(require("node:path"));
const Constants_1 = require("../../lib/Constants");
const utils_1 = require("../utils");
const vitest_1 = require("vitest");
//@ts-expect-error - clifty is ESM only
const clifty_1 = require("clifty");
(0, vitest_1.describe)('Nuxt-3', () => {
let wizardExitCode;
const { projectDir, cleanup } = (0, utils_1.createIsolatedTestEnv)('nuxt-3-test-app');
(0, vitest_1.beforeAll)(async () => {
wizardExitCode = await (0, clifty_1.withEnv)({
cwd: projectDir,
})
.defineInteraction()
.expectOutput('The Sentry Nuxt Wizard will help you set up Sentry for your application')
.whenAsked('Please select your package manager.')
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
.whenAsked('Do you want to add an override for @vercel/nft')
.respondWith(clifty_1.KEYS.ENTER)
.expectOutput('Installing @sentry/nuxt')
.expectOutput('Installed @sentry/nuxt', {
timeout: 240000,
})
.expectOutput('Created .env.sentry-build-plugin')
.whenAsked('Please select your deployment platform')
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.DOWN, clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
.expectOutput('Added Sentry Nuxt Module to nuxt.config.ts')
.whenAsked('Do you want to enable Tracing')
.respondWith(clifty_1.KEYS.ENTER)
.whenAsked('Do you want to enable Session Replay')
.respondWith(clifty_1.KEYS.ENTER)
.whenAsked('Do you want to enable Logs')
.respondWith(clifty_1.KEYS.ENTER)
.expectOutput('Created new sentry.server.config.ts')
.expectOutput('Created new sentry.client.config.ts')
.whenAsked('Do you want to create an example page')
.respondWith(clifty_1.KEYS.ENTER)
.expectOutput('Created pages/index.vue')
.expectOutput('After building your Nuxt app, you need to --import the Sentry server config file when running your app')
.whenAsked('Do you want to open the docs?')
.respondWith(clifty_1.KEYS.RIGHT, clifty_1.KEYS.ENTER) // no
.whenAsked('Optionally add a project-scoped MCP server configuration for the Sentry MCP?')
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
.expectOutput('Successfully installed the Sentry Nuxt SDK!')
.run((0, utils_1.getWizardCommand)(Constants_1.Integration.nuxt));
});
(0, vitest_1.afterAll)(() => {
cleanup();
});
(0, vitest_1.test)('exits with exit code 0', () => {
(0, vitest_1.expect)(wizardExitCode).toBe(0);
});
(0, vitest_1.test)('package.json is updated correctly', () => {
(0, utils_1.checkPackageJson)(projectDir, '@sentry/nuxt');
});
(0, vitest_1.test)('.env-sentry-build-plugin is created and contains the auth token', () => {
(0, utils_1.checkEnvBuildPlugin)(projectDir);
});
(0, vitest_1.test)('config files created', () => {
(0, utils_1.checkFileExists)(`${projectDir}/sentry.server.config.ts`);
(0, utils_1.checkFileExists)(`${projectDir}/sentry.client.config.ts`);
});
(0, vitest_1.test)('example page exists', () => {
(0, utils_1.checkFileExists)(`${projectDir}/pages/sentry-example-page.vue`);
(0, utils_1.checkFileExists)(`${projectDir}/server/api/sentry-example-api.ts`);
});
(0, vitest_1.test)('nuxt config contains sentry module', () => {
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'nuxt.config.ts'), [
"modules: ['@sentry/nuxt/module'],",
'sentry: {',
` org: '${utils_1.TEST_ARGS.ORG_SLUG}',`,
` project: '${utils_1.TEST_ARGS.PROJECT_SLUG}'`,
'},',
'sourcemap: {',
" client: 'hidden'",
'}',
]);
});
(0, vitest_1.test)('sentry.client.config.ts contents', () => {
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'sentry.client.config.ts'), [
'import * as Sentry from "@sentry/nuxt";',
'Sentry.init({',
' // If set up, you can use your runtime config here',
' // dsn: useRuntimeConfig().public.sentry.dsn,',
` dsn: "${utils_1.TEST_ARGS.PROJECT_DSN}",`,
' // 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.test)('sentry.server.config.ts contents', () => {
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'sentry.server.config.ts'), [
'import * as Sentry from "@sentry/nuxt";',
'Sentry.init({',
` dsn: "${utils_1.TEST_ARGS.PROJECT_DSN}",`,
' // 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.test)('builds successfully', async () => {
await (0, utils_1.checkIfBuilds)(projectDir);
});
(0, vitest_1.test)('runs on prod mode correctly', async () => {
await (0, utils_1.checkIfRunsOnProdMode)(projectDir, 'Listening on');
});
});
//# sourceMappingURL=nuxt-3.test.js.map