@sentry/wizard 6.10.0 → 6.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/dist/ci-ensure-runtime-loaded.sh +82 -0
- package/dist/e2e-tests/tests/angular-17.test.js +72 -82
- package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
- package/dist/e2e-tests/tests/angular-19.test.js +71 -80
- package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
- package/dist/e2e-tests/tests/cloudflare-worker.test.d.ts +1 -0
- package/dist/e2e-tests/tests/cloudflare-worker.test.js +69 -0
- package/dist/e2e-tests/tests/cloudflare-worker.test.js.map +1 -0
- package/dist/e2e-tests/tests/cloudflare-wrangler-sourcemaps.test.js +2 -5
- package/dist/e2e-tests/tests/cloudflare-wrangler-sourcemaps.test.js.map +1 -1
- package/dist/e2e-tests/tests/expo.test.js +36 -61
- package/dist/e2e-tests/tests/expo.test.js.map +1 -1
- package/dist/e2e-tests/tests/flutter.test.js +63 -70
- package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
- package/dist/e2e-tests/tests/help-message.test.js +2 -2
- package/dist/e2e-tests/tests/help-message.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-14.test.js +48 -76
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +89 -99
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-16.test.js +48 -45
- package/dist/e2e-tests/tests/nextjs-16.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js +45 -58
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +59 -73
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/pnpm-workspace.test.js +6 -8
- package/dist/e2e-tests/tests/pnpm-workspace.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-native.test.js +44 -80
- package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-router-instrumentation-api.test.d.ts +1 -0
- package/dist/e2e-tests/tests/react-router-instrumentation-api.test.js +96 -0
- package/dist/e2e-tests/tests/react-router-instrumentation-api.test.js.map +1 -0
- package/dist/e2e-tests/tests/react-router.test.js +165 -145
- package/dist/e2e-tests/tests/react-router.test.js.map +1 -1
- package/dist/e2e-tests/tests/remix.test.js +162 -132
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js +48 -36
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js +5 -7
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +15 -43
- package/dist/e2e-tests/utils/index.js +95 -185
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/get-e2e-test-matrix.mjs +11 -0
- package/dist/lib/Constants.d.ts +1 -0
- package/dist/lib/Constants.js +5 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/src/android/android-wizard.js +2 -4
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/angular/angular-wizard.js +4 -6
- package/dist/src/angular/angular-wizard.js.map +1 -1
- package/dist/src/angular/sdk-setup.js +1 -1
- package/dist/src/angular/sdk-setup.js.map +1 -1
- package/dist/src/apple/apple-wizard.js +2 -4
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/code-tools.js +17 -3
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/configure-package-manager.js +18 -5
- package/dist/src/apple/configure-package-manager.js.map +1 -1
- package/dist/src/cloudflare/cloudflare-wizard.d.ts +3 -0
- package/dist/src/cloudflare/cloudflare-wizard.js +104 -0
- package/dist/src/cloudflare/cloudflare-wizard.js.map +1 -0
- package/dist/src/cloudflare/sdk-setup.d.ts +8 -0
- package/dist/src/cloudflare/sdk-setup.js +47 -0
- package/dist/src/cloudflare/sdk-setup.js.map +1 -0
- package/dist/src/cloudflare/templates.d.ts +5 -0
- package/dist/src/cloudflare/templates.js +50 -0
- package/dist/src/cloudflare/templates.js.map +1 -0
- package/dist/src/cloudflare/wrangler/create-wrangler-config.d.ts +4 -0
- package/dist/src/cloudflare/wrangler/create-wrangler-config.js +27 -0
- package/dist/src/cloudflare/wrangler/create-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrangler/ensure-wrangler-config.d.ts +4 -0
- package/dist/src/cloudflare/wrangler/ensure-wrangler-config.js +25 -0
- package/dist/src/cloudflare/wrangler/ensure-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrangler/find-wrangler-config.d.ts +4 -0
- package/dist/src/cloudflare/wrangler/find-wrangler-config.js +23 -0
- package/dist/src/cloudflare/wrangler/find-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.d.ts +6 -0
- package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.js +52 -0
- package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrangler/update-wrangler-config.d.ts +17 -0
- package/dist/src/cloudflare/wrangler/update-wrangler-config.js +173 -0
- package/dist/src/cloudflare/wrangler/update-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrap-worker.d.ts +33 -0
- package/dist/src/cloudflare/wrap-worker.js +116 -0
- package/dist/src/cloudflare/wrap-worker.js.map +1 -0
- package/dist/src/flutter/flutter-wizard.js +3 -6
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +0 -2
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +3 -5
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/react-native/expo.d.ts +6 -0
- package/dist/src/react-native/expo.js +27 -1
- package/dist/src/react-native/expo.js.map +1 -1
- package/dist/src/react-native/git.d.ts +5 -0
- package/dist/src/react-native/git.js +32 -1
- package/dist/src/react-native/git.js.map +1 -1
- package/dist/src/react-native/javascript.js +3 -1
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.js +14 -10
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-router/codemods/client.entry.d.ts +1 -1
- package/dist/src/react-router/codemods/client.entry.js +69 -12
- package/dist/src/react-router/codemods/client.entry.js.map +1 -1
- package/dist/src/react-router/codemods/react-router-config.js +1 -1
- package/dist/src/react-router/codemods/react-router-config.js.map +1 -1
- package/dist/src/react-router/codemods/root.js +1 -2
- package/dist/src/react-router/codemods/root.js.map +1 -1
- package/dist/src/react-router/codemods/server-entry.d.ts +1 -1
- package/dist/src/react-router/codemods/server-entry.js +39 -4
- package/dist/src/react-router/codemods/server-entry.js.map +1 -1
- package/dist/src/react-router/codemods/vite.js +46 -1
- package/dist/src/react-router/codemods/vite.js.map +1 -1
- package/dist/src/react-router/react-router-wizard.js +55 -10
- package/dist/src/react-router/react-router-wizard.js.map +1 -1
- package/dist/src/react-router/sdk-setup.d.ts +5 -3
- package/dist/src/react-router/sdk-setup.js +35 -9
- package/dist/src/react-router/sdk-setup.js.map +1 -1
- package/dist/src/react-router/templates.d.ts +2 -2
- package/dist/src/react-router/templates.js +72 -2
- package/dist/src/react-router/templates.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +2 -4
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/run.d.ts +1 -1
- package/dist/src/run.js +5 -0
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +1 -1
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup/vite.js +1 -1
- package/dist/src/sveltekit/sdk-setup/vite.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +2 -4
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/utils/abort-if-sportlight-not-supported.d.ts +5 -0
- package/dist/src/utils/abort-if-sportlight-not-supported.js +40 -0
- package/dist/src/utils/abort-if-sportlight-not-supported.js.map +1 -0
- package/dist/src/utils/ast-utils.d.ts +11 -1
- package/dist/src/utils/ast-utils.js +19 -1
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/clack/index.d.ts +2 -2
- package/dist/src/utils/clack/index.js.map +1 -1
- package/dist/src/utils/clack/mcp-config.js +117 -59
- package/dist/src/utils/clack/mcp-config.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/test/angular/angular-wizard.test.js +2 -4
- package/dist/test/angular/angular-wizard.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +78 -0
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/configure-package-manager.test.d.ts +1 -0
- package/dist/test/apple/configure-package-manager.test.js +161 -0
- package/dist/test/apple/configure-package-manager.test.js.map +1 -0
- package/dist/test/cloudflare/create-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/create-wrangler-config.test.js +48 -0
- package/dist/test/cloudflare/create-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/ensure-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/ensure-wrangler-config.test.js +61 -0
- package/dist/test/cloudflare/ensure-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/find-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/find-wrangler-config.test.js +77 -0
- package/dist/test/cloudflare/find-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.js +81 -0
- package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/sdk-setup.test.d.ts +1 -0
- package/dist/test/cloudflare/sdk-setup.test.js +170 -0
- package/dist/test/cloudflare/sdk-setup.test.js.map +1 -0
- package/dist/test/cloudflare/templates.test.d.ts +1 -0
- package/dist/test/cloudflare/templates.test.js +122 -0
- package/dist/test/cloudflare/templates.test.js.map +1 -0
- package/dist/test/cloudflare/update-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/update-wrangler-config.test.js +216 -0
- package/dist/test/cloudflare/update-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/wrap-worker.test.d.ts +1 -0
- package/dist/test/cloudflare/wrap-worker.test.js +206 -0
- package/dist/test/cloudflare/wrap-worker.test.js.map +1 -0
- package/dist/test/react-native/expo.test.js +140 -0
- package/dist/test/react-native/expo.test.js.map +1 -1
- package/dist/test/react-native/git.test.d.ts +1 -0
- package/dist/test/react-native/git.test.js +160 -0
- package/dist/test/react-native/git.test.js.map +1 -0
- package/dist/test/react-router/codemods/client-entry.test.js +29 -0
- package/dist/test/react-router/codemods/client-entry.test.js.map +1 -1
- package/dist/test/react-router/codemods/root.test.js +4 -0
- package/dist/test/react-router/codemods/root.test.js.map +1 -1
- package/dist/test/react-router/codemods/server-entry.test.js +70 -0
- package/dist/test/react-router/codemods/server-entry.test.js.map +1 -1
- package/dist/test/react-router/codemods/vite.test.js +89 -0
- package/dist/test/react-router/codemods/vite.test.js.map +1 -1
- package/dist/test/react-router/sdk-setup.test.js +64 -8
- package/dist/test/react-router/sdk-setup.test.js.map +1 -1
- package/dist/test/react-router/templates.test.js +50 -0
- package/dist/test/react-router/templates.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/vite.test.js +12 -8
- package/dist/test/sourcemaps/tools/vite.test.js.map +1 -1
- package/dist/test/utils/ast-utils.test.js +22 -0
- package/dist/test/utils/ast-utils.test.js.map +1 -1
- package/dist/test/utils/clack/mcp-config.test.js +176 -51
- package/dist/test/utils/clack/mcp-config.test.js.map +1 -1
- package/package.json +6 -5
|
@@ -28,136 +28,162 @@ const fs = __importStar(require("node:fs"));
|
|
|
28
28
|
const Constants_1 = require("../../lib/Constants");
|
|
29
29
|
const utils_1 = require("../utils");
|
|
30
30
|
const vitest_1 = require("vitest");
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
'integrations: [Sentry.reactRouterTracingIntegration(), Sentry.replayIntegration()]',
|
|
79
|
-
'enableLogs: true,',
|
|
80
|
-
'tracesSampleRate: 1.0,',
|
|
81
|
-
]);
|
|
82
|
-
});
|
|
83
|
-
(0, vitest_1.test)('package.json scripts are updated correctly', () => {
|
|
84
|
-
(0, utils_1.checkFileContents)(`${projectDir}/package.json`, [
|
|
85
|
-
`"start": "NODE_OPTIONS='--import ./instrument.server.mjs' react-router-serve ./build/server/index.js"`,
|
|
86
|
-
`"dev": "NODE_OPTIONS='--import ./instrument.server.mjs' react-router dev"`,
|
|
87
|
-
]);
|
|
88
|
-
});
|
|
89
|
-
(0, vitest_1.test)('entry.server file contains Sentry instrumentation', () => {
|
|
90
|
-
(0, utils_1.checkFileContents)(`${projectDir}/app/entry.server.tsx`, [
|
|
91
|
-
'import * as Sentry from',
|
|
92
|
-
'@sentry/react-router',
|
|
93
|
-
'export const handleError = Sentry.createSentryHandleError(',
|
|
94
|
-
'export default Sentry.wrapSentryHandleRequest(handleRequest);'
|
|
95
|
-
]);
|
|
96
|
-
});
|
|
97
|
-
(0, vitest_1.test)('instrument.server file contains Sentry initialization', () => {
|
|
98
|
-
(0, utils_1.checkFileContents)(`${projectDir}/instrument.server.mjs`, [
|
|
99
|
-
'import * as Sentry from \'@sentry/react-router\';',
|
|
100
|
-
`Sentry.init({
|
|
101
|
-
dsn: "${utils_1.TEST_ARGS.PROJECT_DSN}",`,
|
|
102
|
-
'enableLogs: true,',
|
|
103
|
-
]);
|
|
104
|
-
});
|
|
105
|
-
(0, vitest_1.test)('root file contains Sentry ErrorBoundary', () => {
|
|
106
|
-
(0, utils_1.checkFileContents)(`${projectDir}/app/root.tsx`, [
|
|
107
|
-
'import * as Sentry from',
|
|
108
|
-
'@sentry/react-router',
|
|
109
|
-
'export function ErrorBoundary',
|
|
110
|
-
'Sentry.captureException(error)',
|
|
111
|
-
]);
|
|
112
|
-
});
|
|
113
|
-
(0, vitest_1.test)('vite.config file contains sentryReactRouter plugin', () => {
|
|
114
|
-
(0, utils_1.checkFileContents)(`${projectDir}/vite.config.ts`, [
|
|
115
|
-
'import { sentryReactRouter } from',
|
|
116
|
-
'@sentry/react-router',
|
|
117
|
-
'sentryReactRouter(',
|
|
118
|
-
'authToken: process.env.SENTRY_AUTH_TOKEN',
|
|
119
|
-
]);
|
|
120
|
-
});
|
|
121
|
-
(0, vitest_1.test)('react-router.config file contains buildEnd hook with sentryOnBuildEnd', () => {
|
|
122
|
-
(0, utils_1.checkFileContents)(`${projectDir}/react-router.config.ts`, [
|
|
123
|
-
'import { sentryOnBuildEnd } from',
|
|
124
|
-
'@sentry/react-router',
|
|
125
|
-
'ssr: true,',
|
|
126
|
-
'buildEnd: async',
|
|
127
|
-
'await sentryOnBuildEnd({',
|
|
128
|
-
]);
|
|
129
|
-
});
|
|
130
|
-
(0, vitest_1.test)('builds successfully', async () => {
|
|
131
|
-
await (0, utils_1.checkIfBuilds)(projectDir);
|
|
132
|
-
}, 60000); // 1 minute timeout
|
|
133
|
-
(0, vitest_1.test)('runs on dev mode correctly', async () => {
|
|
134
|
-
await (0, utils_1.checkIfRunsOnDevMode)(projectDir, 'to expose');
|
|
135
|
-
}, 30000); // 30 second timeout
|
|
136
|
-
(0, vitest_1.test)('runs on prod mode correctly', async () => {
|
|
137
|
-
await (0, utils_1.checkIfRunsOnProdMode)(projectDir, 'react-router-serve');
|
|
138
|
-
}, 30000); // 30 second timeout
|
|
31
|
+
//@ts-expect-error - clifty is ESM only
|
|
32
|
+
const clifty_1 = require("clifty");
|
|
33
|
+
async function runWizardOnReactRouterProject(projectDir, opts) {
|
|
34
|
+
const { modifiedFiles = false } = opts || {};
|
|
35
|
+
const wizardInteraction = (0, clifty_1.withEnv)({
|
|
36
|
+
cwd: projectDir,
|
|
37
|
+
}).defineInteraction();
|
|
38
|
+
if (modifiedFiles) {
|
|
39
|
+
wizardInteraction
|
|
40
|
+
.whenAsked('Do you want to continue anyway?')
|
|
41
|
+
.respondWith(clifty_1.KEYS.ENTER);
|
|
42
|
+
}
|
|
43
|
+
wizardInteraction
|
|
44
|
+
.whenAsked('Please select your package manager.')
|
|
45
|
+
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
|
|
46
|
+
.expectOutput('Installing @sentry/react-router')
|
|
47
|
+
.expectOutput('Installed @sentry/react-router', {
|
|
48
|
+
timeout: 240000,
|
|
49
|
+
})
|
|
50
|
+
.whenAsked('Do you want to enable Tracing')
|
|
51
|
+
.respondWith(clifty_1.KEYS.ENTER)
|
|
52
|
+
.whenAsked('Do you want to enable Session Replay')
|
|
53
|
+
.respondWith(clifty_1.KEYS.ENTER)
|
|
54
|
+
.whenAsked('Do you want to enable Logs')
|
|
55
|
+
.respondWith(clifty_1.KEYS.ENTER)
|
|
56
|
+
.whenAsked('Do you want to enable Profiling')
|
|
57
|
+
.respondWith(clifty_1.KEYS.ENTER)
|
|
58
|
+
.whenAsked('Do you want to use the Instrumentation API')
|
|
59
|
+
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER) // No
|
|
60
|
+
.expectOutput('Installing @sentry/profiling-node')
|
|
61
|
+
.expectOutput('Installed @sentry/profiling-node', {
|
|
62
|
+
timeout: 240000,
|
|
63
|
+
})
|
|
64
|
+
.whenAsked('Do you want to create an example page')
|
|
65
|
+
.respondWith(clifty_1.KEYS.ENTER);
|
|
66
|
+
if (modifiedFiles) {
|
|
67
|
+
wizardInteraction
|
|
68
|
+
.whenAsked('Would you like to try running npx react-router reveal')
|
|
69
|
+
.respondWith(clifty_1.KEYS.ENTER)
|
|
70
|
+
.whenAsked('Did you apply the snippet above?')
|
|
71
|
+
.respondWith(clifty_1.KEYS.ENTER);
|
|
72
|
+
}
|
|
73
|
+
return wizardInteraction
|
|
74
|
+
.whenAsked('Optionally add a project-scoped MCP server configuration for the Sentry MCP?')
|
|
75
|
+
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
|
|
76
|
+
.expectOutput('Successfully installed the Sentry React Router SDK!')
|
|
77
|
+
.run((0, utils_1.getWizardCommand)(Constants_1.Integration.reactRouter));
|
|
139
78
|
}
|
|
140
79
|
(0, vitest_1.describe)('React Router', () => {
|
|
141
80
|
(0, vitest_1.describe)('with empty project', () => {
|
|
142
|
-
|
|
143
|
-
const projectDir =
|
|
81
|
+
let wizardExitCode;
|
|
82
|
+
const { projectDir, cleanup } = (0, utils_1.createIsolatedTestEnv)('react-router-test-app');
|
|
144
83
|
(0, vitest_1.beforeAll)(async () => {
|
|
145
|
-
await runWizardOnReactRouterProject(projectDir
|
|
84
|
+
wizardExitCode = await runWizardOnReactRouterProject(projectDir);
|
|
146
85
|
});
|
|
147
86
|
(0, vitest_1.afterAll)(() => {
|
|
148
|
-
(
|
|
149
|
-
(0, utils_1.cleanupGit)(projectDir);
|
|
87
|
+
cleanup();
|
|
150
88
|
});
|
|
151
|
-
|
|
89
|
+
(0, vitest_1.test)('exits with exit code 0', () => {
|
|
90
|
+
(0, vitest_1.expect)(wizardExitCode).toBe(0);
|
|
91
|
+
});
|
|
92
|
+
(0, vitest_1.test)('package.json is updated correctly', () => {
|
|
93
|
+
(0, utils_1.checkPackageJson)(projectDir, '@sentry/react-router');
|
|
94
|
+
});
|
|
95
|
+
(0, vitest_1.test)('.env.sentry-build-plugin is created and contains the auth token', () => {
|
|
96
|
+
(0, utils_1.checkEnvBuildPlugin)(projectDir);
|
|
97
|
+
});
|
|
98
|
+
(0, vitest_1.test)('example page exists', () => {
|
|
99
|
+
(0, utils_1.checkFileExists)(`${projectDir}/app/routes/sentry-example-page.tsx`);
|
|
100
|
+
});
|
|
101
|
+
(0, vitest_1.test)('example API route exists', () => {
|
|
102
|
+
(0, utils_1.checkFileExists)(`${projectDir}/app/routes/api.sentry-example-api.ts`);
|
|
103
|
+
});
|
|
104
|
+
(0, vitest_1.test)('example page is added to routes configuration', () => {
|
|
105
|
+
(0, utils_1.checkFileContents)(`${projectDir}/app/routes.ts`, [
|
|
106
|
+
'route("/sentry-example-page", "routes/sentry-example-page.tsx")',
|
|
107
|
+
'route("/api/sentry-example-api", "routes/api.sentry-example-api.ts")',
|
|
108
|
+
]);
|
|
109
|
+
});
|
|
110
|
+
(0, vitest_1.test)('instrument.server file exists', () => {
|
|
111
|
+
(0, utils_1.checkFileExists)(`${projectDir}/instrument.server.mjs`);
|
|
112
|
+
});
|
|
113
|
+
(0, vitest_1.test)('entry.client file contains Sentry initialization', () => {
|
|
114
|
+
(0, utils_1.checkFileContents)(`${projectDir}/app/entry.client.tsx`, [
|
|
115
|
+
'import * as Sentry from',
|
|
116
|
+
'@sentry/react-router',
|
|
117
|
+
`Sentry.init({
|
|
118
|
+
dsn: "${utils_1.TEST_ARGS.PROJECT_DSN}",`,
|
|
119
|
+
'integrations: [Sentry.reactRouterTracingIntegration(), Sentry.replayIntegration()]',
|
|
120
|
+
'enableLogs: true,',
|
|
121
|
+
'tracesSampleRate: 1.0,',
|
|
122
|
+
]);
|
|
123
|
+
});
|
|
124
|
+
(0, vitest_1.test)('package.json scripts are updated correctly', () => {
|
|
125
|
+
(0, utils_1.checkFileContents)(`${projectDir}/package.json`, [
|
|
126
|
+
`"start": "NODE_ENV=production NODE_OPTIONS='--import ./instrument.server.mjs' react-router-serve ./build/server/index.js"`,
|
|
127
|
+
`"dev": "NODE_OPTIONS='--import ./instrument.server.mjs' react-router dev"`,
|
|
128
|
+
]);
|
|
129
|
+
});
|
|
130
|
+
(0, vitest_1.test)('entry.server file contains Sentry instrumentation', () => {
|
|
131
|
+
(0, utils_1.checkFileContents)(`${projectDir}/app/entry.server.tsx`, [
|
|
132
|
+
'import * as Sentry from',
|
|
133
|
+
'@sentry/react-router',
|
|
134
|
+
'export const handleError = Sentry.createSentryHandleError(',
|
|
135
|
+
'export default Sentry.wrapSentryHandleRequest(handleRequest);',
|
|
136
|
+
]);
|
|
137
|
+
});
|
|
138
|
+
(0, vitest_1.test)('instrument.server file contains Sentry initialization', () => {
|
|
139
|
+
(0, utils_1.checkFileContents)(`${projectDir}/instrument.server.mjs`, [
|
|
140
|
+
"import * as Sentry from '@sentry/react-router';",
|
|
141
|
+
`Sentry.init({
|
|
142
|
+
dsn: "${utils_1.TEST_ARGS.PROJECT_DSN}",`,
|
|
143
|
+
'enableLogs: true,',
|
|
144
|
+
]);
|
|
145
|
+
});
|
|
146
|
+
(0, vitest_1.test)('root file contains Sentry ErrorBoundary', () => {
|
|
147
|
+
(0, utils_1.checkFileContents)(`${projectDir}/app/root.tsx`, [
|
|
148
|
+
'import * as Sentry from',
|
|
149
|
+
'@sentry/react-router',
|
|
150
|
+
'export function ErrorBoundary',
|
|
151
|
+
'Sentry.captureException(error)',
|
|
152
|
+
]);
|
|
153
|
+
});
|
|
154
|
+
(0, vitest_1.test)('vite.config file contains sentryReactRouter plugin', () => {
|
|
155
|
+
(0, utils_1.checkFileContents)(`${projectDir}/vite.config.ts`, [
|
|
156
|
+
'import { sentryReactRouter } from',
|
|
157
|
+
'@sentry/react-router',
|
|
158
|
+
'sentryReactRouter(',
|
|
159
|
+
'authToken: process.env.SENTRY_AUTH_TOKEN',
|
|
160
|
+
]);
|
|
161
|
+
});
|
|
162
|
+
(0, vitest_1.test)('react-router.config file contains buildEnd hook with sentryOnBuildEnd', () => {
|
|
163
|
+
(0, utils_1.checkFileContents)(`${projectDir}/react-router.config.ts`, [
|
|
164
|
+
'import { sentryOnBuildEnd } from',
|
|
165
|
+
'@sentry/react-router',
|
|
166
|
+
'ssr: true,',
|
|
167
|
+
'buildEnd: async',
|
|
168
|
+
'await sentryOnBuildEnd({',
|
|
169
|
+
]);
|
|
170
|
+
});
|
|
171
|
+
(0, vitest_1.test)('builds successfully', async () => {
|
|
172
|
+
await (0, utils_1.checkIfBuilds)(projectDir);
|
|
173
|
+
}, 60000); // 1 minute timeout
|
|
174
|
+
(0, vitest_1.test)('runs on dev mode correctly', async () => {
|
|
175
|
+
await (0, utils_1.checkIfRunsOnDevMode)(projectDir, 'to expose');
|
|
176
|
+
}, 30000); // 30 second timeout
|
|
177
|
+
(0, vitest_1.test)('runs on prod mode correctly', async () => {
|
|
178
|
+
await (0, utils_1.checkIfRunsOnProdMode)(projectDir, 'react-router-serve');
|
|
179
|
+
}, 30000); // 30 second timeout
|
|
152
180
|
});
|
|
153
181
|
(0, vitest_1.describe)('edge cases', () => {
|
|
154
|
-
const baseProjectDir = path.resolve(__dirname, '../test-applications/react-router-test-app');
|
|
155
182
|
(0, vitest_1.describe)('existing Sentry setup', () => {
|
|
156
|
-
|
|
157
|
-
const projectDir =
|
|
183
|
+
let wizardExitCode;
|
|
184
|
+
const { projectDir, cleanup } = (0, utils_1.createIsolatedTestEnv)('react-router-test-app');
|
|
158
185
|
(0, vitest_1.beforeAll)(async () => {
|
|
159
|
-
//
|
|
160
|
-
fs.cpSync(baseProjectDir, projectDir, { recursive: true });
|
|
186
|
+
// Add existing Sentry setup to the isolated test app
|
|
161
187
|
const clientEntryPath = path.join(projectDir, 'app', 'entry.client.tsx');
|
|
162
188
|
const existingContent = `import * as Sentry from "@sentry/react-router";
|
|
163
189
|
import { startTransition, StrictMode } from "react";
|
|
@@ -178,28 +204,27 @@ startTransition(() => {
|
|
|
178
204
|
);
|
|
179
205
|
});`;
|
|
180
206
|
fs.writeFileSync(clientEntryPath, existingContent);
|
|
181
|
-
await runWizardOnReactRouterProject(projectDir,
|
|
207
|
+
wizardExitCode = await runWizardOnReactRouterProject(projectDir, {
|
|
208
|
+
modifiedFiles: true,
|
|
209
|
+
});
|
|
182
210
|
});
|
|
183
211
|
(0, vitest_1.afterAll)(() => {
|
|
184
|
-
(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
catch (e) {
|
|
190
|
-
// Ignore cleanup errors
|
|
191
|
-
}
|
|
212
|
+
cleanup();
|
|
213
|
+
});
|
|
214
|
+
(0, vitest_1.test)('exits with exit code 0', () => {
|
|
215
|
+
(0, vitest_1.expect)(wizardExitCode).toBe(0);
|
|
192
216
|
});
|
|
193
217
|
(0, vitest_1.test)('wizard handles existing Sentry without duplication', () => {
|
|
194
218
|
const clientContent = fs.readFileSync(`${projectDir}/app/entry.client.tsx`, 'utf8');
|
|
195
219
|
const sentryImportCount = (clientContent.match(/import \* as Sentry from "@sentry\/react-router"/g) || []).length;
|
|
196
|
-
const sentryInitCount = (clientContent.match(/Sentry\.init\(/g) || [])
|
|
220
|
+
const sentryInitCount = (clientContent.match(/Sentry\.init\(/g) || [])
|
|
221
|
+
.length;
|
|
197
222
|
(0, vitest_1.expect)(sentryImportCount).toBe(1);
|
|
198
223
|
(0, vitest_1.expect)(sentryInitCount).toBe(1);
|
|
199
224
|
});
|
|
200
225
|
// Only test the essential checks for this edge case
|
|
201
226
|
(0, vitest_1.test)('package.json is updated correctly', () => {
|
|
202
|
-
(0, utils_1.checkPackageJson)(projectDir,
|
|
227
|
+
(0, utils_1.checkPackageJson)(projectDir, '@sentry/react-router');
|
|
203
228
|
});
|
|
204
229
|
(0, vitest_1.test)('essential files exist or wizard completes gracefully', () => {
|
|
205
230
|
// Check if key directories exist
|
|
@@ -211,42 +236,37 @@ startTransition(() => {
|
|
|
211
236
|
(0, vitest_1.expect)(fs.existsSync(packageJsonPath)).toBe(true);
|
|
212
237
|
const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');
|
|
213
238
|
const packageJson = JSON.parse(packageJsonContent);
|
|
214
|
-
const hasSentryPackage =
|
|
215
|
-
|
|
239
|
+
const hasSentryPackage = packageJson.dependencies?.['@sentry/react-router'] ||
|
|
240
|
+
packageJson.devDependencies?.['@sentry/react-router'];
|
|
216
241
|
// The wizard should have at least installed the Sentry package
|
|
217
242
|
(0, vitest_1.expect)(hasSentryPackage).toBeTruthy();
|
|
218
243
|
});
|
|
219
244
|
});
|
|
220
245
|
(0, vitest_1.describe)('missing entry files', () => {
|
|
221
|
-
|
|
222
|
-
const projectDir =
|
|
246
|
+
let wizardExitCode;
|
|
247
|
+
const { projectDir, cleanup } = (0, utils_1.createIsolatedTestEnv)('react-router-test-app');
|
|
223
248
|
(0, vitest_1.beforeAll)(async () => {
|
|
224
249
|
// Copy project and remove entry files
|
|
225
|
-
fs.cpSync(baseProjectDir, projectDir, { recursive: true });
|
|
226
250
|
const entryClientPath = path.join(projectDir, 'app', 'entry.client.tsx');
|
|
227
251
|
const entryServerPath = path.join(projectDir, 'app', 'entry.server.tsx');
|
|
228
252
|
if (fs.existsSync(entryClientPath))
|
|
229
253
|
fs.unlinkSync(entryClientPath);
|
|
230
254
|
if (fs.existsSync(entryServerPath))
|
|
231
255
|
fs.unlinkSync(entryServerPath);
|
|
232
|
-
await runWizardOnReactRouterProject(projectDir
|
|
256
|
+
wizardExitCode = await runWizardOnReactRouterProject(projectDir);
|
|
233
257
|
});
|
|
234
258
|
(0, vitest_1.afterAll)(() => {
|
|
235
|
-
(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
catch (e) {
|
|
241
|
-
// Ignore cleanup errors
|
|
242
|
-
}
|
|
259
|
+
cleanup();
|
|
260
|
+
});
|
|
261
|
+
(0, vitest_1.test)('exits with exit code 0', () => {
|
|
262
|
+
(0, vitest_1.expect)(wizardExitCode).toBe(0);
|
|
243
263
|
});
|
|
244
264
|
(0, vitest_1.test)('wizard creates missing entry files', () => {
|
|
245
265
|
(0, utils_1.checkFileExists)(`${projectDir}/app/entry.client.tsx`);
|
|
246
266
|
(0, utils_1.checkFileExists)(`${projectDir}/app/entry.server.tsx`);
|
|
247
267
|
});
|
|
248
268
|
(0, vitest_1.test)('basic configuration still works', () => {
|
|
249
|
-
(0, utils_1.checkPackageJson)(projectDir,
|
|
269
|
+
(0, utils_1.checkPackageJson)(projectDir, '@sentry/react-router');
|
|
250
270
|
(0, utils_1.checkFileExists)(`${projectDir}/instrument.server.mjs`);
|
|
251
271
|
});
|
|
252
272
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-router.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/react-router.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,4CAA8B;AAC9B,mDAAkD;AAClD,oCAakB;AAClB,mCAAqE;AAErE,KAAK,UAAU,6BAA6B,CAC1C,UAAkB,EAClB,WAAwB;IAExB,MAAM,cAAc,GAAG,IAAA,2BAAmB,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAEpE,MAAM,sBAAsB,GAAG,MAAM,cAAc,CAAC,aAAa,CAC/D,qCAAqC,CACtC,CAAC;IAEF,MAAM,qBAAqB,GACzB,sBAAsB;QACtB,CAAC,MAAM,cAAc,CAAC,yBAAyB,CAC7C,CAAC,YAAI,CAAC,IAAI,EAAE,YAAI,CAAC,KAAK,CAAC,EACvB,+CAA+C,EAC/C,EAAE,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CAAC","sourcesContent":["import * as path from 'node:path';\nimport * as fs from 'node:fs';\nimport { Integration } from '../../lib/Constants';\nimport {\n KEYS,\n TEST_ARGS,\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n revertLocalChanges,\n startWizardInstance,\n} from '../utils';\nimport { afterAll, beforeAll, describe, test, expect } from 'vitest';\n\nasync function runWizardOnReactRouterProject(\n projectDir: string,\n integration: Integration,\n) {\n const wizardInstance = startWizardInstance(integration, projectDir);\n\n const packageManagerPrompted = await wizardInstance.waitForOutput(\n 'Please select your package manager.',\n );\n\n const tracingOptionPrompted =\n packageManagerPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.DOWN, KEYS.ENTER],\n 'to track the performance of your application?',\n { timeout: 240_000 }\n ));\n\n const replayOptionPrompted =\n tracingOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'to get a video-like reproduction of errors during a user session?'\n ));\n\n const logOptionPrompted =\n replayOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'to send your application logs to Sentry?'\n ));\n\n const profilingOptionPrompted =\n logOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'to track application performance in detail?'\n ));\n\n const examplePagePrompted =\n profilingOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Do you want to create an example page'\n ));\n\n const mcpPrompted =\n examplePagePrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n { optional: true }\n ));\n\n mcpPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.DOWN, KEYS.ENTER],\n 'Successfully installed the Sentry React Router SDK!'\n ));\n\n wizardInstance.kill();\n}\n\nfunction checkReactRouterProject(projectDir: string, integration: Integration) {\n test('package.json is updated correctly', () => {\n checkPackageJson(projectDir, integration);\n });\n\n test('.env.sentry-build-plugin is created and contains the auth token', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n test('example page exists', () => {\n checkFileExists(`${projectDir}/app/routes/sentry-example-page.tsx`);\n });\n\n test('example API route exists', () => {\n checkFileExists(`${projectDir}/app/routes/api.sentry-example-api.ts`);\n });\n\n test('example page is added to routes configuration', () => {\n checkFileContents(`${projectDir}/app/routes.ts`, [\n 'route(\"/sentry-example-page\", \"routes/sentry-example-page.tsx\")',\n 'route(\"/api/sentry-example-api\", \"routes/api.sentry-example-api.ts\")',\n ]);\n });\n\n test('instrument.server file exists', () => {\n checkFileExists(`${projectDir}/instrument.server.mjs`);\n });\n\n test('entry.client file contains Sentry initialization', () => {\n checkFileContents(`${projectDir}/app/entry.client.tsx`, [\n 'import * as Sentry from',\n '@sentry/react-router',\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",`,\n 'integrations: [Sentry.reactRouterTracingIntegration(), Sentry.replayIntegration()]',\n 'enableLogs: true,',\n 'tracesSampleRate: 1.0,',\n ]);\n });\n\n test('package.json scripts are updated correctly', () => {\n checkFileContents(`${projectDir}/package.json`, [\n `\"start\": \"NODE_OPTIONS='--import ./instrument.server.mjs' react-router-serve ./build/server/index.js\"`,\n `\"dev\": \"NODE_OPTIONS='--import ./instrument.server.mjs' react-router dev\"`,\n ]);\n });\n\n test('entry.server file contains Sentry instrumentation', () => {\n checkFileContents(`${projectDir}/app/entry.server.tsx`, [\n 'import * as Sentry from',\n '@sentry/react-router',\n 'export const handleError = Sentry.createSentryHandleError(',\n 'export default Sentry.wrapSentryHandleRequest(handleRequest);'\n ]);\n });\n\n test('instrument.server file contains Sentry initialization', () => {\n checkFileContents(`${projectDir}/instrument.server.mjs`, [\n 'import * as Sentry from \\'@sentry/react-router\\';',\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",`,\n 'enableLogs: true,',\n ]);\n });\n\n test('root file contains Sentry ErrorBoundary', () => {\n checkFileContents(`${projectDir}/app/root.tsx`, [\n 'import * as Sentry from',\n '@sentry/react-router',\n 'export function ErrorBoundary',\n 'Sentry.captureException(error)',\n ]);\n });\n\n test('vite.config file contains sentryReactRouter plugin', () => {\n checkFileContents(`${projectDir}/vite.config.ts`, [\n 'import { sentryReactRouter } from',\n '@sentry/react-router',\n 'sentryReactRouter(',\n 'authToken: process.env.SENTRY_AUTH_TOKEN',\n ]);\n });\n\n test('react-router.config file contains buildEnd hook with sentryOnBuildEnd', () => {\n checkFileContents(`${projectDir}/react-router.config.ts`, [\n 'import { sentryOnBuildEnd } from',\n '@sentry/react-router',\n 'ssr: true,',\n 'buildEnd: async',\n 'await sentryOnBuildEnd({',\n ]);\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n }, 60000); // 1 minute timeout\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(projectDir, 'to expose');\n }, 30000); // 30 second timeout\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(projectDir, 'react-router-serve');\n }, 30000); // 30 second timeout\n}\n\ndescribe('React Router', () => {\n describe('with empty project', () => {\n const integration = Integration.reactRouter;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/react-router-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnReactRouterProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkReactRouterProject(projectDir, integration);\n });\n\n describe('edge cases', () => {\n const baseProjectDir = path.resolve(\n __dirname,\n '../test-applications/react-router-test-app',\n );\n\n describe('existing Sentry setup', () => {\n const integration = Integration.reactRouter;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/react-router-test-app-existing',\n );\n\n beforeAll(async () => {\n // Copy project and add existing Sentry setup\n fs.cpSync(baseProjectDir, projectDir, { recursive: true });\n\n const clientEntryPath = path.join(projectDir, 'app', 'entry.client.tsx');\n const existingContent = `import * as Sentry from \"@sentry/react-router\";\nimport { startTransition, StrictMode } from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\nimport { HydratedRouter } from \"react-router/dom\";\n\nSentry.init({\n dsn: \"https://existing@dsn.ingest.sentry.io/1337\",\n tracesSampleRate: 1.0,\n});\n\nstartTransition(() => {\n hydrateRoot(\n document,\n <StrictMode>\n <HydratedRouter />\n </StrictMode>\n );\n});`;\n fs.writeFileSync(clientEntryPath, existingContent);\n\n await runWizardOnReactRouterProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n try {\n fs.rmSync(projectDir, { recursive: true, force: true });\n } catch (e) {\n // Ignore cleanup errors\n }\n });\n\n test('wizard handles existing Sentry without duplication', () => {\n const clientContent = fs.readFileSync(`${projectDir}/app/entry.client.tsx`, 'utf8');\n const sentryImportCount = (clientContent.match(/import \\* as Sentry from \"@sentry\\/react-router\"/g) || []).length;\n const sentryInitCount = (clientContent.match(/Sentry\\.init\\(/g) || []).length;\n\n expect(sentryImportCount).toBe(1);\n expect(sentryInitCount).toBe(1);\n });\n\n // Only test the essential checks for this edge case\n test('package.json is updated correctly', () => {\n checkPackageJson(projectDir, integration);\n });\n\n test('essential files exist or wizard completes gracefully', () => {\n // Check if key directories exist\n expect(fs.existsSync(`${projectDir}/app`)).toBe(true);\n\n // When there's existing Sentry setup, the wizard may skip some file creation\n // to avoid conflicts. This is acceptable behavior.\n // Let's check if the wizard at least completed by verifying package.json was updated\n const packageJsonPath = `${projectDir}/package.json`;\n expect(fs.existsSync(packageJsonPath)).toBe(true);\n\n const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');\n const packageJson = JSON.parse(packageJsonContent) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n\n const hasSentryPackage =\n (packageJson.dependencies?.['@sentry/react-router']) ||\n (packageJson.devDependencies?.['@sentry/react-router']);\n\n // The wizard should have at least installed the Sentry package\n expect(hasSentryPackage).toBeTruthy();\n });\n });\n\n describe('missing entry files', () => {\n const integration = Integration.reactRouter;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/react-router-test-app-missing-entries',\n );\n\n beforeAll(async () => {\n // Copy project and remove entry files\n fs.cpSync(baseProjectDir, projectDir, { recursive: true });\n\n const entryClientPath = path.join(projectDir, 'app', 'entry.client.tsx');\n const entryServerPath = path.join(projectDir, 'app', 'entry.server.tsx');\n\n if (fs.existsSync(entryClientPath)) fs.unlinkSync(entryClientPath);\n if (fs.existsSync(entryServerPath)) fs.unlinkSync(entryServerPath);\n\n await runWizardOnReactRouterProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n try {\n fs.rmSync(projectDir, { recursive: true, force: true });\n } catch (e) {\n // Ignore cleanup errors\n }\n });\n\n test('wizard creates missing entry files', () => {\n checkFileExists(`${projectDir}/app/entry.client.tsx`);\n checkFileExists(`${projectDir}/app/entry.server.tsx`);\n });\n\n test('basic configuration still works', () => {\n checkPackageJson(projectDir, integration);\n checkFileExists(`${projectDir}/instrument.server.mjs`);\n });\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"react-router.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/react-router.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,4CAA8B;AAC9B,mDAAkD;AAClD,oCAWkB;AAClB,mCAAqE;AAErE,uCAAuC;AACvC,mCAAuC;AAEvC,KAAK,UAAU,6BAA6B,CAC1C,UAAkB,EAClB,IAEC;IAED,MAAM,EAAE,aAAa,GAAG,KAAK,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;IAE7C,MAAM,iBAAiB,GAAG,IAAA,gBAAO,EAAC;QAChC,GAAG,EAAE,UAAU;KAChB,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAEvB,IAAI,aAAa,EAAE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KAAK,EACL,kBAAkB,CACnB,CAAC;gBACF,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAC/B,UAAU,EACV,KAAK,EACL,kBAAkB,CACnB,CAAC;gBAEF,IAAI,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;oBAAE,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;gBACnE,IAAI,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;oBAAE,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;gBAEnE,cAAc,GAAG,MAAM,6BAA6B,CAAC,UAAU,CAAC,CAAC;YACnE,CAAC,CAAC,CAAC;YAEH,IAAA,iBAAQ,EAAC,GAAG,EAAE;gBACZ,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;YAEH,IAAA,aAAI,EAAC,wBAAwB,EAAE,GAAG,EAAE;gBAClC,IAAA,eAAM,EAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACjC,CAAC,CAAC,CAAC;YAEH,IAAA,aAAI,EAAC,oCAAoC,EAAE,GAAG,EAAE;gBAC9C,IAAA,uBAAe,EAAC,GAAG,UAAU,uBAAuB,CAAC,CAAC;gBACtD,IAAA,uBAAe,EAAC,GAAG,UAAU,uBAAuB,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;YAEH,IAAA,aAAI,EAAC,iCAAiC,EAAE,GAAG,EAAE;gBAC3C,IAAA,wBAAgB,EAAC,UAAU,EAAE,sBAAsB,CAAC,CAAC;gBACrD,IAAA,uBAAe,EAAC,GAAG,UAAU,wBAAwB,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as path from 'node:path';\nimport * as fs from 'node:fs';\nimport { Integration } from '../../lib/Constants';\nimport {\n TEST_ARGS,\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n createIsolatedTestEnv,\n getWizardCommand,\n} from '../utils';\nimport { afterAll, beforeAll, describe, test, expect } from 'vitest';\n\n//@ts-expect-error - clifty is ESM only\nimport { KEYS, withEnv } from 'clifty';\n\nasync function runWizardOnReactRouterProject(\n projectDir: string,\n opts?: {\n modifiedFiles?: boolean;\n },\n): Promise<number> {\n const { modifiedFiles = false } = opts || {};\n\n const wizardInteraction = withEnv({\n cwd: projectDir,\n }).defineInteraction();\n\n if (modifiedFiles) {\n wizardInteraction\n .whenAsked('Do you want to continue anyway?')\n .respondWith(KEYS.ENTER);\n }\n\n wizardInteraction\n .whenAsked('Please select your package manager.')\n .respondWith(KEYS.DOWN, KEYS.ENTER)\n .expectOutput('Installing @sentry/react-router')\n .expectOutput('Installed @sentry/react-router', {\n timeout: 240_000,\n })\n\n .whenAsked('Do you want to enable Tracing')\n .respondWith(KEYS.ENTER)\n .whenAsked('Do you want to enable Session Replay')\n .respondWith(KEYS.ENTER)\n .whenAsked('Do you want to enable Logs')\n .respondWith(KEYS.ENTER)\n .whenAsked('Do you want to enable Profiling')\n .respondWith(KEYS.ENTER)\n .whenAsked('Do you want to use the Instrumentation API')\n .respondWith(KEYS.DOWN, KEYS.ENTER) // No\n .expectOutput('Installing @sentry/profiling-node')\n .expectOutput('Installed @sentry/profiling-node', {\n timeout: 240_000,\n })\n .whenAsked('Do you want to create an example page')\n .respondWith(KEYS.ENTER);\n\n if (modifiedFiles) {\n wizardInteraction\n .whenAsked('Would you like to try running npx react-router reveal')\n .respondWith(KEYS.ENTER)\n .whenAsked('Did you apply the snippet above?')\n .respondWith(KEYS.ENTER);\n }\n\n return wizardInteraction\n .whenAsked(\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n )\n .respondWith(KEYS.DOWN, KEYS.ENTER)\n .expectOutput('Successfully installed the Sentry React Router SDK!')\n .run(getWizardCommand(Integration.reactRouter));\n}\n\ndescribe('React Router', () => {\n describe('with empty project', () => {\n let wizardExitCode: number;\n const { projectDir, cleanup } = createIsolatedTestEnv(\n 'react-router-test-app',\n );\n\n beforeAll(async () => {\n wizardExitCode = await runWizardOnReactRouterProject(projectDir);\n });\n\n afterAll(() => {\n cleanup();\n });\n\n test('exits with exit code 0', () => {\n expect(wizardExitCode).toBe(0);\n });\n\n test('package.json is updated correctly', () => {\n checkPackageJson(projectDir, '@sentry/react-router');\n });\n\n test('.env.sentry-build-plugin is created and contains the auth token', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n test('example page exists', () => {\n checkFileExists(`${projectDir}/app/routes/sentry-example-page.tsx`);\n });\n\n test('example API route exists', () => {\n checkFileExists(`${projectDir}/app/routes/api.sentry-example-api.ts`);\n });\n\n test('example page is added to routes configuration', () => {\n checkFileContents(`${projectDir}/app/routes.ts`, [\n 'route(\"/sentry-example-page\", \"routes/sentry-example-page.tsx\")',\n 'route(\"/api/sentry-example-api\", \"routes/api.sentry-example-api.ts\")',\n ]);\n });\n\n test('instrument.server file exists', () => {\n checkFileExists(`${projectDir}/instrument.server.mjs`);\n });\n\n test('entry.client file contains Sentry initialization', () => {\n checkFileContents(`${projectDir}/app/entry.client.tsx`, [\n 'import * as Sentry from',\n '@sentry/react-router',\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",`,\n 'integrations: [Sentry.reactRouterTracingIntegration(), Sentry.replayIntegration()]',\n 'enableLogs: true,',\n 'tracesSampleRate: 1.0,',\n ]);\n });\n\n test('package.json scripts are updated correctly', () => {\n checkFileContents(`${projectDir}/package.json`, [\n `\"start\": \"NODE_ENV=production NODE_OPTIONS='--import ./instrument.server.mjs' react-router-serve ./build/server/index.js\"`,\n `\"dev\": \"NODE_OPTIONS='--import ./instrument.server.mjs' react-router dev\"`,\n ]);\n });\n\n test('entry.server file contains Sentry instrumentation', () => {\n checkFileContents(`${projectDir}/app/entry.server.tsx`, [\n 'import * as Sentry from',\n '@sentry/react-router',\n 'export const handleError = Sentry.createSentryHandleError(',\n 'export default Sentry.wrapSentryHandleRequest(handleRequest);',\n ]);\n });\n\n test('instrument.server file contains Sentry initialization', () => {\n checkFileContents(`${projectDir}/instrument.server.mjs`, [\n \"import * as Sentry from '@sentry/react-router';\",\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",`,\n 'enableLogs: true,',\n ]);\n });\n\n test('root file contains Sentry ErrorBoundary', () => {\n checkFileContents(`${projectDir}/app/root.tsx`, [\n 'import * as Sentry from',\n '@sentry/react-router',\n 'export function ErrorBoundary',\n 'Sentry.captureException(error)',\n ]);\n });\n\n test('vite.config file contains sentryReactRouter plugin', () => {\n checkFileContents(`${projectDir}/vite.config.ts`, [\n 'import { sentryReactRouter } from',\n '@sentry/react-router',\n 'sentryReactRouter(',\n 'authToken: process.env.SENTRY_AUTH_TOKEN',\n ]);\n });\n\n test('react-router.config file contains buildEnd hook with sentryOnBuildEnd', () => {\n checkFileContents(`${projectDir}/react-router.config.ts`, [\n 'import { sentryOnBuildEnd } from',\n '@sentry/react-router',\n 'ssr: true,',\n 'buildEnd: async',\n 'await sentryOnBuildEnd({',\n ]);\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n }, 60_000); // 1 minute timeout\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(projectDir, 'to expose');\n }, 30_000); // 30 second timeout\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(projectDir, 'react-router-serve');\n }, 30_000); // 30 second timeout\n });\n\n describe('edge cases', () => {\n describe('existing Sentry setup', () => {\n let wizardExitCode: number;\n\n const { projectDir, cleanup } = createIsolatedTestEnv(\n 'react-router-test-app',\n );\n\n beforeAll(async () => {\n // Add existing Sentry setup to the isolated test app\n const clientEntryPath = path.join(\n projectDir,\n 'app',\n 'entry.client.tsx',\n );\n const existingContent = `import * as Sentry from \"@sentry/react-router\";\nimport { startTransition, StrictMode } from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\nimport { HydratedRouter } from \"react-router/dom\";\n\nSentry.init({\n dsn: \"https://existing@dsn.ingest.sentry.io/1337\",\n tracesSampleRate: 1.0,\n});\n\nstartTransition(() => {\n hydrateRoot(\n document,\n <StrictMode>\n <HydratedRouter />\n </StrictMode>\n );\n});`;\n fs.writeFileSync(clientEntryPath, existingContent);\n\n wizardExitCode = await runWizardOnReactRouterProject(projectDir, {\n modifiedFiles: true,\n });\n });\n\n afterAll(() => {\n cleanup();\n });\n\n test('exits with exit code 0', () => {\n expect(wizardExitCode).toBe(0);\n });\n\n test('wizard handles existing Sentry without duplication', () => {\n const clientContent = fs.readFileSync(\n `${projectDir}/app/entry.client.tsx`,\n 'utf8',\n );\n const sentryImportCount = (\n clientContent.match(\n /import \\* as Sentry from \"@sentry\\/react-router\"/g,\n ) || []\n ).length;\n const sentryInitCount = (clientContent.match(/Sentry\\.init\\(/g) || [])\n .length;\n\n expect(sentryImportCount).toBe(1);\n expect(sentryInitCount).toBe(1);\n });\n\n // Only test the essential checks for this edge case\n test('package.json is updated correctly', () => {\n checkPackageJson(projectDir, '@sentry/react-router');\n });\n\n test('essential files exist or wizard completes gracefully', () => {\n // Check if key directories exist\n expect(fs.existsSync(`${projectDir}/app`)).toBe(true);\n\n // When there's existing Sentry setup, the wizard may skip some file creation\n // to avoid conflicts. This is acceptable behavior.\n // Let's check if the wizard at least completed by verifying package.json was updated\n const packageJsonPath = `${projectDir}/package.json`;\n expect(fs.existsSync(packageJsonPath)).toBe(true);\n\n const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');\n const packageJson = JSON.parse(packageJsonContent) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n\n const hasSentryPackage =\n packageJson.dependencies?.['@sentry/react-router'] ||\n packageJson.devDependencies?.['@sentry/react-router'];\n\n // The wizard should have at least installed the Sentry package\n expect(hasSentryPackage).toBeTruthy();\n });\n });\n\n describe('missing entry files', () => {\n let wizardExitCode: number;\n\n const { projectDir, cleanup } = createIsolatedTestEnv(\n 'react-router-test-app',\n );\n\n beforeAll(async () => {\n // Copy project and remove entry files\n\n const entryClientPath = path.join(\n projectDir,\n 'app',\n 'entry.client.tsx',\n );\n const entryServerPath = path.join(\n projectDir,\n 'app',\n 'entry.server.tsx',\n );\n\n if (fs.existsSync(entryClientPath)) fs.unlinkSync(entryClientPath);\n if (fs.existsSync(entryServerPath)) fs.unlinkSync(entryServerPath);\n\n wizardExitCode = await runWizardOnReactRouterProject(projectDir);\n });\n\n afterAll(() => {\n cleanup();\n });\n\n test('exits with exit code 0', () => {\n expect(wizardExitCode).toBe(0);\n });\n\n test('wizard creates missing entry files', () => {\n checkFileExists(`${projectDir}/app/entry.client.tsx`);\n checkFileExists(`${projectDir}/app/entry.server.tsx`);\n });\n\n test('basic configuration still works', () => {\n checkPackageJson(projectDir, '@sentry/react-router');\n checkFileExists(`${projectDir}/instrument.server.mjs`);\n });\n });\n });\n});\n"]}
|