@sentry/wizard
Version:
Sentry wizard helping you to configure your project
134 lines • 7.19 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 fs = __importStar(require("node:fs"));
const Constants_1 = require("../../lib/Constants");
const utils_1 = require("../utils");
const utils_2 = require("../utils");
const vitest_1 = require("vitest");
//@ts-expect-error - clifty is ESM only
const clifty_1 = require("clifty");
(0, vitest_1.describe)('Flutter', () => {
(0, vitest_1.describe)('with apple platforms', () => {
let wizardExitCode;
const { projectDir, cleanup } = (0, utils_1.createIsolatedTestEnv)('flutter-test-app');
(0, vitest_1.beforeAll)(async () => {
wizardExitCode = await (0, clifty_1.withEnv)({
cwd: projectDir,
debug: true,
})
.defineInteraction()
.expectOutput('The Sentry Flutter Wizard will help you set up Sentry for your application')
.whenAsked('Do you want to enable Tracing')
.respondWith(clifty_1.KEYS.ENTER)
.whenAsked('to analyze CPU usage and optimize performance-critical code on iOS & macOS?')
.respondWith(clifty_1.KEYS.ENTER)
.whenAsked('to record user interactions and debug issues?')
.respondWith(clifty_1.KEYS.ENTER)
.whenAsked('to send your application logs to Sentry?')
.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('Successfully installed the Sentry Flutter SDK!')
.run((0, utils_1.getWizardCommand)(Constants_1.Integration.flutter));
});
(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)('pubspec.yaml is updated.', () => {
(0, utils_2.checkFileContents)(`${projectDir}/pubspec.yaml`, `sentry_flutter:`); // dependencies
(0, utils_2.checkFileContents)(`${projectDir}/pubspec.yaml`, `sentry_dart_plugin:`); // dev_dependencies
(0, utils_2.checkFileContents)(`${projectDir}/pubspec.yaml`, `sentry:`); // gradle plugin options
});
(0, vitest_1.test)('sentry.properties exists and has auth token', () => {
(0, utils_2.checkSentryProperties)(projectDir);
});
(0, vitest_1.test)('.gitignore has sentry.properties', () => {
(0, utils_2.checkFileContents)(`${projectDir}/.gitignore`, `sentry.properties`);
});
(0, vitest_1.test)('lib/main.dart calls sentry init', () => {
(0, utils_2.checkFileContents)(`${projectDir}/lib/main.dart`, `import 'package:sentry_flutter/sentry_flutter.dart';`);
(0, utils_2.checkFileContents)(`${projectDir}/lib/main.dart`, `await SentryFlutter.init(`);
});
(0, vitest_1.test)('lib/main.dart enables tracing and profiling', () => {
(0, utils_2.checkFileContents)(`${projectDir}/lib/main.dart`, `options.tracesSampleRate = 1.0;`);
(0, utils_2.checkFileContents)(`${projectDir}/lib/main.dart`, `options.profilesSampleRate = 1.0;`);
});
(0, vitest_1.test)('lib/main.dart enables logs', () => {
(0, utils_2.checkFileContents)(`${projectDir}/lib/main.dart`, `options.enableLogs = true;`);
});
(0, vitest_1.test)('builds correctly', async () => {
await (0, utils_2.checkIfFlutterBuilds)(projectDir, '✓ Built build/web');
});
});
(0, vitest_1.describe)('without apple platforms', () => {
let wizardExitCode;
const { projectDir, cleanup } = (0, utils_1.createIsolatedTestEnv)('flutter-test-app');
(0, vitest_1.beforeAll)(async () => {
// Remove apple platform directories to simulate non-apple setup
if (fs.existsSync(`${projectDir}/ios`)) {
fs.renameSync(`${projectDir}/ios`, `${projectDir}/_ios`);
}
if (fs.existsSync(`${projectDir}/macos`)) {
fs.renameSync(`${projectDir}/macos`, `${projectDir}/_macos`);
}
wizardExitCode = await (0, clifty_1.withEnv)({
cwd: projectDir,
debug: true,
})
.defineInteraction()
.whenAsked('Do you want to continue anyway?')
.respondWith(clifty_1.KEYS.ENTER)
.expectOutput('The Sentry Flutter Wizard will help you set up Sentry for your application')
.whenAsked('Do you want to enable Tracing')
.respondWith(clifty_1.KEYS.ENTER)
.whenAsked('to record user interactions and debug issues?')
.respondWith(clifty_1.KEYS.ENTER)
.whenAsked('to send your application logs to Sentry?')
.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('Successfully installed the Sentry Flutter SDK!')
.run((0, utils_1.getWizardCommand)(Constants_1.Integration.flutter));
});
(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)('lib/main.dart does not add profiling with missing ios and macos folder', () => {
const fileContent = fs.readFileSync(`${projectDir}/lib/main.dart`, 'utf-8');
(0, vitest_1.expect)(fileContent).not.toContain(`options.profilesSampleRate = 1.0;`);
});
(0, vitest_1.test)('lib/main.dart enables logs', () => {
(0, utils_2.checkFileContents)(`${projectDir}/lib/main.dart`, `options.enableLogs = true;`);
});
});
});
//# sourceMappingURL=flutter.test.js.map