@sentry/wizard
Version:
Sentry wizard helping you to configure your project
105 lines (98 loc) • 4.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
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)('Expo', () => {
let wizardExitCode;
const { projectDir, cleanup } = (0, utils_1.createIsolatedTestEnv)('react-native-expo-test-app');
(0, vitest_1.beforeAll)(async () => {
wizardExitCode = await (0, clifty_1.withEnv)({
cwd: projectDir,
})
.defineInteraction()
.whenAsked('Please select your package manager.')
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
.expectOutput('Installing @sentry/react-native')
.expectOutput('Installed @sentry/react-native', {
timeout: 240000,
})
.whenAsked('Do you want to enable Session Replay')
.respondWith(clifty_1.KEYS.ENTER)
.whenAsked('Do you want to enable the Feedback Widget to collect feedback from your users?')
.respondWith(clifty_1.KEYS.ENTER)
.whenAsked('Do you want to enable Logs')
.respondWith(clifty_1.KEYS.ENTER)
.expectOutput('Added Sentry.init to app/_layout.tsx')
.expectOutput('Added Sentry Expo plugin to app.config.json')
.expectOutput('Added .env.local to .gitignore')
.expectOutput('Written .env.local')
.expectOutput('Created metro.config.js with Sentry configuration')
.whenAsked('Optionally add a project-scoped MCP server configuration for the Sentry MCP?')
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
.expectOutput('To make sure everything is set up correctly, put the following code snippet into your application.')
.whenAsked('Have you successfully sent a test event?')
.respondWith(clifty_1.KEYS.ENTER)
.expectOutput('Everything is set up!')
.run((0, utils_1.getWizardCommand)(Constants_1.Integration.reactNative));
});
(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.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