-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
test(solidstart): Add client performance e2e tests #12895
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
// @refresh reload | ||
import * as Sentry from '@sentry/solidstart'; | ||
import { solidRouterBrowserTracingIntegration } from '@sentry/solidstart/solidrouter'; | ||
import { StartClient, mount } from '@solidjs/start/client'; | ||
|
||
Sentry.init({ | ||
// We can't use env variables here, seems like they are stripped | ||
// out in production builds. | ||
dsn: 'https://[email protected]/1337', | ||
environment: 'qa', // dynamic sampling bias to keep transactions | ||
integrations: [Sentry.browserTracingIntegration()], | ||
integrations: [solidRouterBrowserTracingIntegration()], | ||
tunnel: 'http://localhost:3031/', // proxy server | ||
// Performance Monitoring | ||
tracesSampleRate: 1.0, // Capture 100% of the transactions | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { useParams } from '@solidjs/router'; | ||
|
||
export default function User() { | ||
const params = useParams(); | ||
return <div>User ID: {params.id}</div>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { waitForTransaction } from '@sentry-internal/test-utils'; | ||
|
||
test('sends a pageload transaction', async ({ page }) => { | ||
const transactionPromise = waitForTransaction('solidstart', async transactionEvent => { | ||
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload'; | ||
}); | ||
|
||
await page.goto('/'); | ||
const pageloadTransaction = await transactionPromise; | ||
|
||
expect(pageloadTransaction).toMatchObject({ | ||
contexts: { | ||
trace: { | ||
op: 'pageload', | ||
origin: 'auto.pageload.browser', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Follow up task: We likely want to emit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, will update this in a follow up PR. |
||
}, | ||
}, | ||
transaction: '/', | ||
transaction_info: { | ||
source: 'url', | ||
}, | ||
}); | ||
}); | ||
|
||
test('sends a navigation transaction', async ({ page }) => { | ||
const transactionPromise = waitForTransaction('solidstart', async transactionEvent => { | ||
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'navigation'; | ||
}); | ||
|
||
await page.goto(`/`); | ||
await page.locator('#navLink').click(); | ||
const navigationTransaction = await transactionPromise; | ||
|
||
expect(navigationTransaction).toMatchObject({ | ||
contexts: { | ||
trace: { | ||
op: 'navigation', | ||
origin: 'auto.navigation.solid.solidrouter', | ||
}, | ||
}, | ||
transaction: '/users/5', | ||
transaction_info: { | ||
source: 'url', | ||
}, | ||
}); | ||
}); | ||
|
||
test('updates the transaction when using the back button', async ({ page }) => { | ||
// Solid Router sends a `-1` navigation when using the back button. | ||
// The sentry solidRouterBrowserTracingIntegration tries to update such | ||
// transactions with the proper name once the `useLocation` hook triggers. | ||
const navigationTxnPromise = waitForTransaction('solidstart', async transactionEvent => { | ||
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'navigation'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The waitForTransaction here and the one in the test above may leak into eachother. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
}); | ||
|
||
await page.goto(`/`); | ||
await page.locator('#navLink').click(); | ||
const navigationTxn = await navigationTxnPromise; | ||
|
||
expect(navigationTxn).toMatchObject({ | ||
contexts: { | ||
trace: { | ||
op: 'navigation', | ||
origin: 'auto.navigation.solid.solidrouter', | ||
}, | ||
}, | ||
transaction: '/users/5', | ||
transaction_info: { | ||
source: 'url', | ||
}, | ||
}); | ||
|
||
const backNavigationTxnPromise = waitForTransaction('solidstart', async transactionEvent => { | ||
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'navigation'; | ||
}); | ||
|
||
await page.goBack(); | ||
const backNavigationTxn = await backNavigationTxnPromise; | ||
|
||
expect(backNavigationTxn).toMatchObject({ | ||
contexts: { | ||
trace: { | ||
op: 'navigation', | ||
origin: 'auto.navigation.solid.solidrouter', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Follow-up, this should probably be |
||
}, | ||
}, | ||
transaction: '/', | ||
transaction_info: { | ||
source: 'url', | ||
}, | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to assert for a particular transaction name, otherwise the tests are gonna start leaking once you add more page.goto()s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated