-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
test(remix): Add client-side integration tests. #5477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
packages/remix/test/integration/app/routes/capture-exception.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as Sentry from '@sentry/remix'; | ||
|
||
export default function ErrorBoundaryCapture() { | ||
Sentry.captureException(new Error('Sentry Manually Captured Error')); | ||
|
||
return <div></div>; | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/remix/test/integration/app/routes/capture-message.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as Sentry from '@sentry/remix'; | ||
|
||
export default function ErrorBoundaryCapture() { | ||
Sentry.captureMessage('Sentry Manually Captured Message'); | ||
|
||
return <div></div>; | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/remix/test/integration/app/routes/error-boundary-capture/$id.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { useState } from 'react'; | ||
|
||
export default function ErrorBoundaryCapture() { | ||
const [count, setCount] = useState(0); | ||
|
||
if (count > 0) { | ||
throw new Error('Sentry React Component Error'); | ||
} else { | ||
setTimeout(() => setCount(count + 1), 0); | ||
} | ||
|
||
return <div>{count}</div>; | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/remix/test/integration/app/routes/manual-tracing/$id.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as Sentry from '@sentry/remix'; | ||
|
||
export default function ManualTracing() { | ||
const transaction = Sentry.startTransaction({ name: 'test_transaction_1' }); | ||
transaction.finish(); | ||
return <div>{}</div>; | ||
AbhiPrasad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
25 changes: 25 additions & 0 deletions
25
packages/remix/test/integration/test/client/capture-exception.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { getMultipleSentryEnvelopeRequests } from './utils/helpers'; | ||
import { test, expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
test('should report a manually captured error.', async ({ page }) => { | ||
const envelopes = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url: '/capture-exception' }); | ||
|
||
const [errorEnvelope, pageloadEnvelope] = envelopes; | ||
|
||
expect(errorEnvelope.level).toBe('error'); | ||
expect(errorEnvelope.tags?.transaction).toBe('/capture-exception'); | ||
expect(errorEnvelope.exception?.values).toMatchObject([ | ||
{ | ||
type: 'Error', | ||
value: 'Sentry Manually Captured Error', | ||
stacktrace: { frames: expect.any(Array) }, | ||
mechanism: { type: 'generic', handled: true }, | ||
}, | ||
]); | ||
|
||
expect(pageloadEnvelope.contexts?.trace.op).toBe('pageload'); | ||
expect(pageloadEnvelope.tags?.['routing.instrumentation']).toBe('remix-router'); | ||
expect(pageloadEnvelope.type).toBe('transaction'); | ||
expect(pageloadEnvelope.transaction).toBe('routes/capture-exception'); | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/remix/test/integration/test/client/capture-message.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { getMultipleSentryEnvelopeRequests } from './utils/helpers'; | ||
import { test, expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
test('should report a manually captured message.', async ({ page }) => { | ||
const envelopes = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url: '/capture-message' }); | ||
|
||
const [messageEnvelope, pageloadEnvelope] = envelopes; | ||
|
||
expect(messageEnvelope.level).toBe('info'); | ||
expect(messageEnvelope.tags?.transaction).toBe('/capture-message'); | ||
expect(messageEnvelope.message).toBe('Sentry Manually Captured Message'); | ||
|
||
expect(pageloadEnvelope.contexts?.trace.op).toBe('pageload'); | ||
expect(pageloadEnvelope.tags?.['routing.instrumentation']).toBe('remix-router'); | ||
expect(pageloadEnvelope.type).toBe('transaction'); | ||
expect(pageloadEnvelope.transaction).toBe('routes/capture-message'); | ||
}); |
32 changes: 32 additions & 0 deletions
32
packages/remix/test/integration/test/client/errorboundary.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { getMultipleSentryEnvelopeRequests } from './utils/helpers'; | ||
import { test, expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
test('should capture React component errors.', async ({ page }) => { | ||
const envelopes = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { | ||
url: '/error-boundary-capture/0', | ||
}); | ||
|
||
const [pageloadEnvelope, errorEnvelope] = envelopes; | ||
|
||
expect(pageloadEnvelope.contexts?.trace.op).toBe('pageload'); | ||
expect(pageloadEnvelope.tags?.['routing.instrumentation']).toBe('remix-router'); | ||
expect(pageloadEnvelope.type).toBe('transaction'); | ||
expect(pageloadEnvelope.transaction).toBe('routes/error-boundary-capture/$id'); | ||
|
||
expect(errorEnvelope.level).toBe('error'); | ||
expect(errorEnvelope.sdk?.name).toBe('sentry.javascript.remix'); | ||
expect(errorEnvelope.exception?.values).toMatchObject([ | ||
{ | ||
type: 'React ErrorBoundary Error', | ||
value: 'Sentry React Component Error', | ||
stacktrace: { frames: expect.any(Array) }, | ||
}, | ||
{ | ||
type: 'Error', | ||
value: 'Sentry React Component Error', | ||
stacktrace: { frames: expect.any(Array) }, | ||
mechanism: { type: 'generic', handled: true }, | ||
}, | ||
]); | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/remix/test/integration/test/client/manualtracing.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { getMultipleSentryEnvelopeRequests } from './utils/helpers'; | ||
import { test, expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
test('should report a manually created / finished transaction.', async ({ page }) => { | ||
const envelopes = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { | ||
url: '/manual-tracing/0', | ||
}); | ||
|
||
const [manualTransactionEnvelope, pageloadEnvelope] = envelopes; | ||
|
||
expect(manualTransactionEnvelope.transaction).toBe('test_transaction_1'); | ||
expect(manualTransactionEnvelope.sdk?.name).toBe('sentry.javascript.remix'); | ||
expect(manualTransactionEnvelope.start_timestamp).toBeDefined(); | ||
expect(manualTransactionEnvelope.timestamp).toBeDefined(); | ||
|
||
expect(pageloadEnvelope.contexts?.trace.op).toBe('pageload'); | ||
expect(pageloadEnvelope.tags?.['routing.instrumentation']).toBe('remix-router'); | ||
expect(pageloadEnvelope.type).toBe('transaction'); | ||
expect(pageloadEnvelope.transaction).toBe('routes/manual-tracing/$id'); | ||
}); |
29 changes: 29 additions & 0 deletions
29
packages/remix/test/integration/test/client/meta-tags.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('should inject `sentry-trace` and `baggage` meta tags inside the root page.', async ({ page }) => { | ||
await page.goto('/'); | ||
|
||
const sentryTraceTag = await page.$('meta[name="sentry-trace"]'); | ||
const sentryTraceContent = await sentryTraceTag?.getAttribute('content'); | ||
|
||
expect(sentryTraceContent).toEqual(expect.any(String)); | ||
|
||
const sentryBaggageTag = await page.$('meta[name="baggage"]'); | ||
const sentryBaggageContent = await sentryBaggageTag?.getAttribute('content'); | ||
|
||
expect(sentryBaggageContent).toEqual(expect.any(String)); | ||
}); | ||
|
||
test('should inject `sentry-trace` and `baggage` meta tags inside a parameterized route.', async ({ page }) => { | ||
await page.goto('/loader-json-response/0'); | ||
|
||
const sentryTraceTag = await page.$('meta[name="sentry-trace"]'); | ||
const sentryTraceContent = await sentryTraceTag?.getAttribute('content'); | ||
|
||
expect(sentryTraceContent).toEqual(expect.any(String)); | ||
|
||
const sentryBaggageTag = await page.$('meta[name="baggage"]'); | ||
const sentryBaggageContent = await sentryBaggageTag?.getAttribute('content'); | ||
|
||
expect(sentryBaggageContent).toEqual(expect.any(String)); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.