UNPKG

@sentry/wizard

Version:

Sentry wizard helping you to configure your project

174 lines (164 loc) 7.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const templates_1 = require("../../src/apple/templates"); (0, vitest_1.describe)('templates', () => { (0, vitest_1.describe)('getRunScriptTemplate', () => { const variations = [ { uploadSource: true, includeHomebrewPath: true, expectedScript: `# This script is responsible for uploading debug symbols and source context for Sentry. if [[ "$(uname -m)" == arm64 ]]; then export PATH="/opt/homebrew/bin:$PATH" fi if which sentry-cli >/dev/null; then export SENTRY_ORG=test-org export SENTRY_PROJECT=test-project ERROR=$(sentry-cli debug-files upload --include-sources "$DWARF_DSYM_FOLDER_PATH" 2>&1 >/dev/null) if [ ! $? -eq 0 ]; then echo "warning: sentry-cli - $ERROR" fi else echo "warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases" fi `, }, { uploadSource: true, includeHomebrewPath: false, expectedScript: `# This script is responsible for uploading debug symbols and source context for Sentry. if which sentry-cli >/dev/null; then export SENTRY_ORG=test-org export SENTRY_PROJECT=test-project ERROR=$(sentry-cli debug-files upload --include-sources "$DWARF_DSYM_FOLDER_PATH" 2>&1 >/dev/null) if [ ! $? -eq 0 ]; then echo "warning: sentry-cli - $ERROR" fi else echo "warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases" fi `, }, { uploadSource: false, includeHomebrewPath: true, expectedScript: `# This script is responsible for uploading debug symbols and source context for Sentry. if [[ "$(uname -m)" == arm64 ]]; then export PATH="/opt/homebrew/bin:$PATH" fi if which sentry-cli >/dev/null; then export SENTRY_ORG=test-org export SENTRY_PROJECT=test-project ERROR=$(sentry-cli debug-files upload "$DWARF_DSYM_FOLDER_PATH" 2>&1 >/dev/null) if [ ! $? -eq 0 ]; then echo "warning: sentry-cli - $ERROR" fi else echo "warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases" fi `, }, { uploadSource: false, includeHomebrewPath: false, expectedScript: `# This script is responsible for uploading debug symbols and source context for Sentry. if which sentry-cli >/dev/null; then export SENTRY_ORG=test-org export SENTRY_PROJECT=test-project ERROR=$(sentry-cli debug-files upload "$DWARF_DSYM_FOLDER_PATH" 2>&1 >/dev/null) if [ ! $? -eq 0 ]; then echo "warning: sentry-cli - $ERROR" fi else echo "warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases" fi `, }, ]; for (const variation of variations) { (0, vitest_1.describe)(`uploadSource: ${variation.uploadSource.toString()} and includeHomebrewPath: ${variation.includeHomebrewPath.toString()}`, () => { (0, vitest_1.it)('should return the correct script', () => { // -- ct -- const script = (0, templates_1.getRunScriptTemplate)('test-org', 'test-project', variation.uploadSource, variation.includeHomebrewPath); // -- Assert -- (0, vitest_1.expect)(script).toBe(variation.expectedScript); }); }); } }); (0, vitest_1.describe)('scriptInputPath', () => { (0, vitest_1.it)('should return the correct path', () => { (0, vitest_1.expect)(templates_1.scriptInputPath).toBe('"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}"'); }); }); (0, vitest_1.describe)('getSwiftSnippet', () => { (0, vitest_1.it)('should return the correct snippet', () => { // -- Arrange -- const snippet = (0, templates_1.getSwiftSnippet)('test-dsn'); // -- Assert -- (0, vitest_1.expect)(snippet).toBe(` SentrySDK.start { options in options.dsn = "test-dsn" options.debug = true // Enabled debug when first installing is always helpful // Adds IP for users. // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ options.sendDefaultPii = true // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // We recommend adjusting this value in production. options.tracesSampleRate = 1.0 // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more. options.configureProfiling = { $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production. $0.lifecycle = .trace } // Uncomment the following lines to add more data to your events // options.attachScreenshot = true // This adds a screenshot to the error events // options.attachViewHierarchy = true // This adds the view hierarchy to the error events } // Remove the next line after confirming that your Sentry integration is working. SentrySDK.capture(message: "This app uses Sentry! :)") `); }); }); (0, vitest_1.describe)('getObjcSnippet', () => { (0, vitest_1.it)('should return the correct snippet', () => { // -- Arrange -- const snippet = (0, templates_1.getObjcSnippet)('test-dsn'); // -- Assert -- (0, vitest_1.expect)(snippet).toBe(` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) { options.dsn = @"test-dsn"; options.debug = YES; // Enabled debug when first installing is always helpful // Adds IP for users. // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ options.sendDefaultPii = YES; // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // We recommend adjusting this value in production. options.tracesSampleRate = @1.0; // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more. options.configureProfiling = ^(SentryProfileOptions *profiling) { profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production. profiling.lifecycle = SentryProfilingLifecycleTrace; }; //Uncomment the following lines to add more data to your events //options.attachScreenshot = YES; //This will add a screenshot to the error events //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events }]; //Remove the next line after confirming that your Sentry integration is working. [SentrySDK captureMessage:@"This app uses Sentry!"]; `); }); }); (0, vitest_1.describe)('getFastlaneSnippet', () => { (0, vitest_1.it)('should return the correct snippet', () => { // -- Arrange -- const snippet = (0, templates_1.getFastlaneSnippet)('test-org', 'test-project'); // -- Assert -- (0, vitest_1.expect)(snippet).toBe(` sentry_cli( org_slug: 'test-org', project_slug: 'test-project', include_sources: true )`); }); }); }); //# sourceMappingURL=templates.test.js.map