UNPKG

@sentry/wizard

Version:

Sentry wizard helping you to configure your project

69 lines 3.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const Constants_1 = require("../../lib/Constants"); const utils_1 = require("../utils"); //@ts-expect-error - clifty is ESM only const clifty_1 = require("clifty"); (0, vitest_1.describe)('cloudflare-worker', () => { const integration = Constants_1.Integration.cloudflare; let wizardExitCode; let expectedCompatibilityDate; const { projectDir, cleanup } = (0, utils_1.createIsolatedTestEnv)('cloudflare-test-app'); (0, vitest_1.beforeAll)(async () => { // Capture the date before running the wizard (wizard runs in subprocess) expectedCompatibilityDate = new Date().toISOString().slice(0, 10); wizardExitCode = await (0, clifty_1.withEnv)({ cwd: projectDir, }) .defineInteraction() .expectOutput('The Sentry Cloudflare Wizard will help you set up Sentry for your application') .step('package installation', ({ expectOutput, whenAsked }) => { whenAsked('Please select your package manager.').respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER); expectOutput('Installing @sentry/cloudflare'); }) .step('SDK setup', ({ whenAsked }) => { whenAsked('Do you want to enable Tracing', { timeout: 90000, // package installation can take a while in CI }).respondWith(clifty_1.KEYS.ENTER); whenAsked('Do you want to enable Logs', { timeout: 90000, // package installation can take a while in CI }).respondWith(clifty_1.KEYS.ENTER); }) .whenAsked('Optionally add a project-scoped MCP server configuration for the Sentry MCP?') .respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER) .expectOutput('Sentry has been successfully configured for your Cloudflare project.') .run((0, utils_1.getWizardCommand)(integration)); }); (0, vitest_1.afterAll)(() => { cleanup(); }); (0, vitest_1.it)('exits with exit code 0', () => { (0, vitest_1.expect)(wizardExitCode).toBe(0); }); (0, vitest_1.it)('adds the SDK dependency to package.json', () => { (0, utils_1.checkPackageJson)(projectDir, '@sentry/cloudflare'); }); (0, vitest_1.it)('builds correctly', async () => { await (0, utils_1.checkIfBuilds)(projectDir); }); (0, vitest_1.it)('wrangler.jsonc file contains Sentry configuration', () => { (0, utils_1.checkFileContents)(`${projectDir}/wrangler.jsonc`, [ `"compatibility_date": "${expectedCompatibilityDate}"`, '"global_fetch_strictly_public"', '"nodejs_als"', '"version_metadata": {', '"binding": "CF_VERSION_METADATA"', ]); }); (0, vitest_1.it)('modifies the worker file to include Sentry initialization', () => { (0, utils_1.checkFileContents)(`${projectDir}/src/index.ts`, [ 'import * as Sentry from "@sentry/cloudflare";', 'export default Sentry.withSentry(env => ({', 'dsn: "https://public@dsn.ingest.sentry.io/1337",', 'tracesSampleRate: 1', 'enableLogs: true', ]); }); }); //# sourceMappingURL=cloudflare-worker.test.js.map