-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): Update
react-router-6
test to avoid sending to Sentry (#…
…12313) Part of #11910 I renamed `standard-frontend-react` to `react-router-6` as this is more descriptive (what does standard frontend even mean?). This test now also uses the event proxy.
- Loading branch information
Showing
18 changed files
with
138 additions
and
240 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
File renamed without changes.
File renamed without changes.
This file contains 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
7 changes: 7 additions & 0 deletions
7
dev-packages/e2e-tests/test-applications/react-router-6/playwright.config.mjs
This file contains 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 { getPlaywrightConfig } from '@sentry-internal/test-utils'; | ||
|
||
const config = getPlaywrightConfig({ | ||
startCommand: `pnpm start`, | ||
}); | ||
|
||
export default config; |
File renamed without changes.
File renamed without changes.
This file contains 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
This file contains 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
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
dev-packages/e2e-tests/test-applications/react-router-6/start-event-proxy.mjs
This file contains 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,6 @@ | ||
import { startEventProxyServer } from '@sentry-internal/test-utils'; | ||
|
||
startEventProxyServer({ | ||
port: 3031, | ||
proxyServerName: 'react-router-6', | ||
}); |
59 changes: 59 additions & 0 deletions
59
dev-packages/e2e-tests/test-applications/react-router-6/tests/errors.test.ts
This file contains 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,59 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { waitForError, waitForTransaction } from '@sentry-internal/test-utils'; | ||
|
||
test('Sends correct error event', async ({ page }) => { | ||
const errorEventPromise = waitForError('react-router-6', event => { | ||
return !event.type && event.exception?.values?.[0]?.value === 'I am an error!'; | ||
}); | ||
|
||
await page.goto('/'); | ||
|
||
const exceptionButton = page.locator('id=exception-button'); | ||
await exceptionButton.click(); | ||
|
||
const errorEvent = await errorEventPromise; | ||
|
||
expect(errorEvent.exception?.values).toHaveLength(1); | ||
expect(errorEvent.exception?.values?.[0]?.value).toBe('I am an error!'); | ||
|
||
expect(errorEvent.request).toEqual({ | ||
headers: expect.any(Object), | ||
url: 'http://localhost:3030/', | ||
}); | ||
|
||
expect(errorEvent.transaction).toEqual('/'); | ||
|
||
expect(errorEvent.contexts?.trace).toEqual({ | ||
trace_id: expect.any(String), | ||
span_id: expect.any(String), | ||
}); | ||
}); | ||
|
||
test('Sets correct transactionName', async ({ page }) => { | ||
const transactionPromise = waitForTransaction('react-router-6', async transactionEvent => { | ||
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload'; | ||
}); | ||
|
||
const errorEventPromise = waitForError('react-router-6', event => { | ||
return !event.type && event.exception?.values?.[0]?.value === 'I am an error!'; | ||
}); | ||
|
||
await page.goto('/'); | ||
const transactionEvent = await transactionPromise; | ||
|
||
// Only capture error once transaction was sent | ||
const exceptionButton = page.locator('id=exception-button'); | ||
await exceptionButton.click(); | ||
|
||
const errorEvent = await errorEventPromise; | ||
|
||
expect(errorEvent.exception?.values).toHaveLength(1); | ||
expect(errorEvent.exception?.values?.[0]?.value).toBe('I am an error!'); | ||
|
||
expect(errorEvent.transaction).toEqual('/'); | ||
|
||
expect(errorEvent.contexts?.trace).toEqual({ | ||
trace_id: transactionEvent.contexts?.trace?.trace_id, | ||
span_id: expect.not.stringContaining(transactionEvent.contexts?.trace?.span_id || ''), | ||
}); | ||
}); |
56 changes: 56 additions & 0 deletions
56
dev-packages/e2e-tests/test-applications/react-router-6/tests/transactions.test.ts
This file contains 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,56 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { waitForTransaction } from '@sentry-internal/test-utils'; | ||
|
||
test('sends a pageload transaction with a parameterized URL', async ({ page }) => { | ||
const transactionPromise = waitForTransaction('react-router-6', async transactionEvent => { | ||
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload'; | ||
}); | ||
|
||
await page.goto(`/`); | ||
|
||
const rootSpan = await transactionPromise; | ||
|
||
expect(rootSpan).toMatchObject({ | ||
contexts: { | ||
trace: { | ||
op: 'pageload', | ||
origin: 'auto.pageload.react.reactrouter_v6', | ||
}, | ||
}, | ||
transaction: '/', | ||
transaction_info: { | ||
source: 'route', | ||
}, | ||
}); | ||
}); | ||
|
||
test('sends a navigation transaction with a parameterized URL', async ({ page }) => { | ||
page.on('console', msg => console.log(msg.text())); | ||
const pageloadTxnPromise = waitForTransaction('react-router-6', async transactionEvent => { | ||
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload'; | ||
}); | ||
|
||
const navigationTxnPromise = waitForTransaction('react-router-6', async transactionEvent => { | ||
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'navigation'; | ||
}); | ||
|
||
await page.goto(`/`); | ||
await pageloadTxnPromise; | ||
|
||
const linkElement = page.locator('id=navigation'); | ||
|
||
const [_, navigationTxn] = await Promise.all([linkElement.click(), navigationTxnPromise]); | ||
|
||
expect(navigationTxn).toMatchObject({ | ||
contexts: { | ||
trace: { | ||
op: 'navigation', | ||
origin: 'auto.navigation.react.reactrouter_v6', | ||
}, | ||
}, | ||
transaction: '/user/:id', | ||
transaction_info: { | ||
source: 'route', | ||
}, | ||
}); | ||
}); |
File renamed without changes.
70 changes: 0 additions & 70 deletions
70
dev-packages/e2e-tests/test-applications/standard-frontend-react/playwright.config.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.