@sentry/wizard
Version:
Sentry wizard helping you to configure your project
130 lines (123 loc) • 6.46 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");
(0, vitest_1.describe)('Expo', () => {
const integration = Constants_1.Integration.reactNative;
const projectDir = path.resolve(__dirname, '../test-applications/react-native-expo-test-app');
(0, vitest_1.beforeAll)(async () => {
const wizardInstance = (0, utils_1.startWizardInstance)(integration, projectDir);
const packageManagerPrompted = await wizardInstance.waitForOutput('Please select your package manager.');
const sessionReplayPrompted = packageManagerPrompted &&
(await wizardInstance.sendStdinAndWaitForOutput(
// Selecting `yarn` as the package manager
[utils_1.KEYS.DOWN, utils_1.KEYS.DOWN, utils_1.KEYS.ENTER], 'Do you want to enable Session Replay to help debug issues? (See https://docs.sentry.io/platforms/react-native/session-replay/)'),
{
timeout: 240000,
});
const feedbackWidgetPrompted = sessionReplayPrompted &&
(await wizardInstance.sendStdinAndWaitForOutput(
// Enable session replay
[utils_1.KEYS.ENTER], 'Do you want to enable the Feedback Widget to collect feedback from your users? (See https://docs.sentry.io/platforms/react-native/user-feedback/)'));
const logsPrompted = feedbackWidgetPrompted &&
(await wizardInstance.sendStdinAndWaitForOutput(
// Enable feedback widget
[utils_1.KEYS.ENTER], 'Do you want to enable Logs? (See https://docs.sentry.io/platforms/react-native/logs/)'));
// Handle the MCP prompt (default is now Yes, so press DOWN to select No)
const mcpPrompted = logsPrompted &&
(await wizardInstance.sendStdinAndWaitForOutput(
// Enable logs
[utils_1.KEYS.ENTER], 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?', {
optional: true,
}));
const testEventPrompted = mcpPrompted &&
(await wizardInstance.sendStdinAndWaitForOutput(
// Decline MCP config by selecting No
[utils_1.KEYS.DOWN, utils_1.KEYS.ENTER], 'Have you successfully sent a test event?'));
testEventPrompted &&
(await wizardInstance.sendStdinAndWaitForOutput(
// Respond that test event was sent
[utils_1.KEYS.ENTER], 'Everything is set up!'));
wizardInstance.kill();
});
(0, vitest_1.afterAll)(() => {
(0, utils_1.revertLocalChanges)(projectDir);
(0, utils_1.cleanupGit)(projectDir);
});
(0, vitest_1.test)('package.json is updated correctly', () => {
(0, utils_1.checkFileContents)(`${projectDir}/package.json`, `@sentry/react-native`);
});
(0, vitest_1.test)('_layout.tsx is updated correctly', () => {
(0, utils_1.checkFileContents)(`${projectDir}/app/_layout.tsx`, `import * as Sentry from '@sentry/react-native';
Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
// Adds more context data to events (IP address, cookies, user, etc.)
// For more information, visit: https://docs.sentry.io/platforms/react-native/data-management/data-collected/
sendDefaultPii: true,
// Enable Logs
enableLogs: true,
// Configure Session Replay
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1,
integrations: [Sentry.mobileReplayIntegration(), Sentry.feedbackIntegration()],
// uncomment the line below to enable Spotlight (https://spotlightjs.com)
// spotlight: __DEV__,
});`);
(0, utils_1.checkFileContents)(`${projectDir}/app/_layout.tsx`, `export default Sentry.wrap(function RootLayout() {`);
});
(0, vitest_1.test)('app.json is updated correctly', () => {
(0, utils_1.checkFileContents)(`${projectDir}/app.json`, `"@sentry/react-native/expo",
{
"url": "https://sentry.io/",
"project": "${utils_1.TEST_ARGS.PROJECT_SLUG}",
"organization": "${utils_1.TEST_ARGS.ORG_SLUG}"
}`);
});
(0, vitest_1.test)('metro.config.js is added', () => {
(0, utils_1.checkFileExists)(`${projectDir}/metro.config.js`);
(0, utils_1.checkFileContents)(`${projectDir}/metro.config.js`, `const { getSentryExpoConfig } = require("@sentry/react-native/metro");
const config = getSentryExpoConfig(__dirname);
module.exports = config;`);
});
(0, vitest_1.test)('.gitignore is updated correctly', () => {
(0, utils_1.checkFileContents)(`${projectDir}/.gitignore`, `.env.local`);
});
(0, vitest_1.test)('android project is bundled correctly', async () => {
const bundled = await (0, utils_1.checkIfExpoBundles)(projectDir, 'android');
(0, vitest_1.expect)(bundled).toBe(true);
});
(0, vitest_1.test)('ios project is bundled correctly', async () => {
const bundled = await (0, utils_1.checkIfExpoBundles)(projectDir, 'ios');
(0, vitest_1.expect)(bundled).toBe(true);
});
(0, vitest_1.test)('web project is bundled correctly', async () => {
const bundled = await (0, utils_1.checkIfExpoBundles)(projectDir, 'web');
(0, vitest_1.expect)(bundled).toBe(true);
});
});
//# sourceMappingURL=expo.test.js.map