Skip to content

Commit d06b72b

Browse files
authored
test(remix): Run tsc before Remix E2E tests (#16345)
Following up: #16336
1 parent 93b72ff commit d06b72b

File tree

26 files changed

+161
-96
lines changed

26 files changed

+161
-96
lines changed

dev-packages/e2e-tests/test-applications/create-remix-app-express-vite-dev/app/entry.client.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ import * as Sentry from '@sentry/remix';
33
import { StrictMode, startTransition, useEffect } from 'react';
44
import { hydrateRoot } from 'react-dom/client';
55

6+
// Extend the Window interface to include ENV
7+
declare global {
8+
interface Window {
9+
ENV: {
10+
SENTRY_DSN: string;
11+
[key: string]: unknown;
12+
};
13+
}
14+
}
15+
616
Sentry.init({
717
environment: 'qa', // dynamic sampling bias to keep transactions
818
dsn: window.ENV.SENTRY_DSN,

dev-packages/e2e-tests/test-applications/create-remix-app-express-vite-dev/app/entry.server.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ function isBotRequest(userAgent: string | null) {
4040
return isbotModule.isbot(userAgent);
4141
}
4242

43-
// isbot < 3.8.0
44-
if ('default' in isbotModule && typeof isbotModule.default === 'function') {
45-
return isbotModule.default(userAgent);
46-
}
47-
4843
return false;
4944
}
5045

dev-packages/e2e-tests/test-applications/create-remix-app-express-vite-dev/app/root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function ErrorBoundary() {
5252
}
5353

5454
function App() {
55-
const { ENV } = useLoaderData();
55+
const { ENV } = useLoaderData() as { ENV: { SENTRY_DSN: string } };
5656

5757
return (
5858
<html lang="en">

dev-packages/e2e-tests/test-applications/create-remix-app-express-vite-dev/app/routes/navigate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const loader: LoaderFunction = async ({ params: { id } }) => {
1010
};
1111

1212
export default function LoaderError() {
13-
const data = useLoaderData();
13+
const data = useLoaderData() as { test?: string };
1414

1515
return (
1616
<div>

dev-packages/e2e-tests/test-applications/create-remix-app-express-vite-dev/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"sideEffects": false,
44
"scripts": {
5-
"build": "remix vite:build",
5+
"build": "remix vite:build && pnpm typecheck",
66
"dev": "node ./server.mjs",
77
"lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
88
"start": "cross-env NODE_ENV=production node ./server.mjs",

dev-packages/e2e-tests/test-applications/create-remix-app-express/app/entry.client.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ import * as Sentry from '@sentry/remix';
33
import { StrictMode, startTransition, useEffect } from 'react';
44
import { hydrateRoot } from 'react-dom/client';
55

6+
// Extend the Window interface to include ENV
7+
declare global {
8+
interface Window {
9+
ENV: {
10+
SENTRY_DSN: string;
11+
[key: string]: unknown;
12+
};
13+
}
14+
}
15+
616
Sentry.init({
717
environment: 'qa', // dynamic sampling bias to keep transactions
818
dsn: window.ENV.SENTRY_DSN,

dev-packages/e2e-tests/test-applications/create-remix-app-express/app/entry.server.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ function isBotRequest(userAgent: string | null) {
4040
return isbotModule.isbot(userAgent);
4141
}
4242

43-
// isbot < 3.8.0
44-
if ('default' in isbotModule && typeof isbotModule.default === 'function') {
45-
return isbotModule.default(userAgent);
46-
}
47-
4843
return false;
4944
}
5045

dev-packages/e2e-tests/test-applications/create-remix-app-express/app/root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function ErrorBoundary() {
5252
}
5353

5454
function App() {
55-
const { ENV } = useLoaderData();
55+
const { ENV } = useLoaderData() as { ENV: { SENTRY_DSN: string } };
5656

5757
return (
5858
<html lang="en">

dev-packages/e2e-tests/test-applications/create-remix-app-express/app/routes/navigate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const loader: LoaderFunction = async ({ params: { id } }) => {
1010
};
1111

1212
export default function LoaderError() {
13-
const data = useLoaderData();
13+
const data = useLoaderData() as { test?: string };
1414

1515
return (
1616
<div>

dev-packages/e2e-tests/test-applications/create-remix-app-express/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"sideEffects": false,
44
"type": "module",
55
"scripts": {
6-
"build": "remix vite:build",
6+
"build": "remix vite:build && pnpm typecheck",
77
"dev": "node ./server.mjs",
88
"lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
99
"start": "cross-env NODE_ENV=production node ./server.mjs",

dev-packages/e2e-tests/test-applications/create-remix-app-express/tests/server-errors.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { waitForError } from '@sentry-internal/test-utils';
33

44
test('Sends a loader error to Sentry', async ({ page }) => {
55
const loaderErrorPromise = waitForError('create-remix-app-express', errorEvent => {
6-
return errorEvent.exception.values[0].value === 'Loader Error';
6+
return errorEvent?.exception?.values?.[0]?.value === 'Loader Error';
77
});
88

99
await page.goto('/loader-error');

dev-packages/e2e-tests/test-applications/create-remix-app-express/tests/server-transactions.test.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test('Sends parameterized transaction name to Sentry', async ({ page }) => {
2020

2121
test('Sends form data with action span', async ({ page }) => {
2222
const formdataActionTransaction = waitForTransaction('create-remix-app-express', transactionEvent => {
23-
return transactionEvent?.spans?.some(span => span.data && span.data['code.function'] === 'action');
23+
return transactionEvent?.spans?.some(span => span.data && span.data['code.function'] === 'action') || false;
2424
});
2525

2626
await page.goto('/action-formdata');
@@ -34,31 +34,31 @@ test('Sends form data with action span', async ({ page }) => {
3434

3535
await page.locator('button[type=submit]').click();
3636

37-
const actionSpan = (await formdataActionTransaction).spans.find(
37+
const actionSpan = (await formdataActionTransaction)?.spans?.find(
3838
span => span.data && span.data['code.function'] === 'action',
3939
);
4040

4141
expect(actionSpan).toBeDefined();
42-
expect(actionSpan.op).toBe('action.remix');
43-
expect(actionSpan.data).toMatchObject({
42+
expect(actionSpan?.op).toBe('action.remix');
43+
expect(actionSpan?.data).toMatchObject({
4444
'formData.text': 'test',
4545
'formData.file': 'file.txt',
4646
});
4747
});
4848

4949
test('Sends a loader span to Sentry', async ({ page }) => {
5050
const loaderTransactionPromise = waitForTransaction('create-remix-app-express', transactionEvent => {
51-
return transactionEvent?.spans?.some(span => span.data && span.data['code.function'] === 'loader');
51+
return transactionEvent?.spans?.some(span => span.data && span.data['code.function'] === 'loader') || false;
5252
});
5353

5454
await page.goto('/');
5555

56-
const loaderSpan = (await loaderTransactionPromise).spans.find(
56+
const loaderSpan = (await loaderTransactionPromise)?.spans?.find(
5757
span => span.data && span.data['code.function'] === 'loader',
5858
);
5959

6060
expect(loaderSpan).toBeDefined();
61-
expect(loaderSpan.op).toBe('loader.remix');
61+
expect(loaderSpan?.op).toBe('loader.remix');
6262
});
6363

6464
test('Propagates trace when ErrorBoundary is triggered', async ({ page }) => {
@@ -83,9 +83,8 @@ test('Propagates trace when ErrorBoundary is triggered', async ({ page }) => {
8383

8484
const httpServerTraceId = httpServerTransaction.contexts?.trace?.trace_id;
8585
const httpServerSpanId = httpServerTransaction.contexts?.trace?.span_id;
86-
const loaderSpanId = httpServerTransaction.spans.find(
87-
span => span.data && span.data['code.function'] === 'loader',
88-
)?.span_id;
86+
const loaderSpanId = httpServerTransaction?.spans?.find(span => span.data && span.data['code.function'] === 'loader')
87+
?.span_id;
8988

9089
const pageLoadTraceId = pageloadTransaction.contexts?.trace?.trace_id;
9190
const pageLoadSpanId = pageloadTransaction.contexts?.trace?.span_id;

dev-packages/e2e-tests/test-applications/create-remix-app-express/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"include": ["env.d.ts", "**/*.ts", "**/*.tsx"],
2+
"include": ["env.d.ts", "./app/**/*.ts", "./app/**/*.tsx"],
33
"compilerOptions": {
44
"lib": ["DOM", "DOM.Iterable", "ES2022"],
55
"isolatedModules": true,

dev-packages/e2e-tests/test-applications/create-remix-app-v2/app/entry.client.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
* For more information, see https://remix.run/file-conventions/entry.client
55
*/
66

7+
// Extend the Window interface to include ENV
8+
declare global {
9+
interface Window {
10+
ENV: {
11+
SENTRY_DSN: string;
12+
[key: string]: unknown;
13+
};
14+
}
15+
}
16+
717
import { RemixBrowser, useLocation, useMatches } from '@remix-run/react';
818
import * as Sentry from '@sentry/remix';
919
import { StrictMode, startTransition, useEffect } from 'react';

dev-packages/e2e-tests/test-applications/create-remix-app-v2/app/root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function ErrorBoundary() {
5252
}
5353

5454
function App() {
55-
const { ENV } = useLoaderData();
55+
const { ENV } = useLoaderData() as { ENV: { SENTRY_DSN: string } };
5656

5757
return (
5858
<html lang="en">

dev-packages/e2e-tests/test-applications/create-remix-app-v2/app/routes/navigate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const loader: LoaderFunction = async ({ params: { id } }) => {
1010
};
1111

1212
export default function LoaderError() {
13-
const data = useLoaderData();
13+
const data = useLoaderData() as { test?: string };
1414

1515
return (
1616
<div>

dev-packages/e2e-tests/test-applications/create-remix-app-v2/package.json

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"sideEffects": false,
44
"scripts": {
5-
"build": "remix build",
5+
"build": "remix build && pnpm typecheck",
66
"dev": "remix dev",
77
"start": "NODE_OPTIONS='--require=./instrument.server.cjs' remix-serve build/index.js",
88
"typecheck": "tsc",
@@ -12,24 +12,28 @@
1212
},
1313
"dependencies": {
1414
"@sentry/remix": "latest || *",
15-
"@remix-run/css-bundle": "2.16.5",
16-
"@remix-run/node": "2.16.5",
17-
"@remix-run/react": "2.16.5",
18-
"@remix-run/serve": "2.16.5",
15+
"@remix-run/css-bundle": "2.16.7",
16+
"@remix-run/node": "2.16.7",
17+
"@remix-run/react": "2.16.7",
18+
"@remix-run/serve": "2.16.7",
1919
"isbot": "^3.6.8",
2020
"react": "^18.2.0",
2121
"react-dom": "^18.2.0"
2222
},
2323
"devDependencies": {
2424
"@playwright/test": "~1.50.0",
2525
"@sentry-internal/test-utils": "link:../../../test-utils",
26-
"@remix-run/dev": "2.16.5",
27-
"@remix-run/eslint-config": "2.16.5",
26+
"@remix-run/dev": "2.16.7",
27+
"@remix-run/eslint-config": "2.16.7",
2828
"@sentry/core": "latest || *",
29-
"@types/react": "^18.0.35",
30-
"@types/react-dom": "^18.0.11",
29+
"@types/react": "^18.2.64",
30+
"@types/react-dom": "^18.2.34",
31+
"@types/prop-types": "15.7.7",
3132
"eslint": "^8.38.0",
32-
"typescript": "^5.0.4"
33+
"typescript": "^5.1.6"
34+
},
35+
"resolutions": {
36+
"@types/react": "18.2.22"
3337
},
3438
"volta": {
3539
"extends": "../../package.json"

dev-packages/e2e-tests/test-applications/create-remix-app-v2/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
2+
"include": ["remix.env.d.ts", "./app/**/*.ts", "./app/**/*.tsx"],
3+
"exclude": ["node_modules", "build"],
34
"compilerOptions": {
45
"lib": ["DOM", "DOM.Iterable", "ES2019"],
56
"isolatedModules": true,
@@ -10,6 +11,7 @@
1011
"target": "ES2019",
1112
"strict": true,
1213
"allowJs": true,
14+
"skipLibCheck": true,
1315
"forceConsistentCasingInFileNames": true,
1416
"baseUrl": ".",
1517
"paths": {
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
import { createPagesFunctionHandler } from '@remix-run/cloudflare-pages';
2-
import { sentryPagesPlugin } from '@sentry/cloudflare';
1+
import {createPagesFunctionHandler} from '@remix-run/cloudflare-pages';
2+
import {sentryPagesPlugin} from '@sentry/cloudflare';
33

44
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
55
// @ts-ignore - the server build file is generated by `remix vite:build`
66
// eslint-disable-next-line import/no-unresolved
77
import * as build from '../build/server';
88

99
export const onRequest = [
10-
context => sentryPagesPlugin({ dsn: context.env.E2E_TEST_DSN, tracesSampleRate: 1.0 })(context),
11-
createPagesFunctionHandler({ build }),
10+
(context: EventPluginContext<any, any, any, any>) =>
11+
sentryPagesPlugin({
12+
dsn: context.env.E2E_TEST_DSN,
13+
tracesSampleRate: 1.0,
14+
})(context),
15+
createPagesFunctionHandler({build}),
1216
];

dev-packages/e2e-tests/test-applications/remix-hydrogen/app/lib/search.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)