-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
test(nextjs): Migrate Next SDK's client side tests to Playwright. #6718
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 all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
523e133
test(nextjs): Migrate Next SDK's client side tests to Playwright.
onurtemizkan 667ddf5
Fix linter.
onurtemizkan af9a2d6
Exclude integration tests from Jest runner.
onurtemizkan 386f066
Add server.js back.
onurtemizkan eb34768
Skip client-side integration tests on node < 14.
onurtemizkan 155b29a
Remove unused `puppeteer` dependencies from `nextjs` package.
onurtemizkan bf09a6b
Resolve conflicts.
onurtemizkan 65b4c0b
Use the latest `next` by default as before.
onurtemizkan 3950398
Reset `tsconfig` to its original implementation.
onurtemizkan 494e3e0
Update NextJS 13+ configuration.
onurtemizkan 8817c2f
Increase default `countEnvelopes` timeout to reduce flakiness.
onurtemizkan 248e4f7
Revisit exit / continue logic for Node versions 17+.
onurtemizkan 725c8ad
Restore package.json in cleanup trap.
onurtemizkan 1e90f9a
Force move `package.json` on cleanup.
onurtemizkan 9ea25b3
Mock `fetch` test API to avoid flakiness due to speed.
onurtemizkan 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
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
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
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
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
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,16 @@ | ||
import type { PlaywrightTestConfig } from '@playwright/test'; | ||
|
||
const config: PlaywrightTestConfig = { | ||
retries: 2, | ||
timeout: 12000, | ||
use: { | ||
baseURL: 'http://localhost:3000', | ||
}, | ||
workers: 3, | ||
webServer: { | ||
command: 'yarn test:integration:prepare', | ||
port: 3000, | ||
}, | ||
}; | ||
|
||
export default config; |
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
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
packages/nextjs/test/integration/test/client/errorClick.js
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
packages/nextjs/test/integration/test/client/errorClick.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,17 @@ | ||
import { getMultipleSentryEnvelopeRequests } from './utils/helpers'; | ||
import { test, expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
test('should capture error triggered on click', async ({ page }) => { | ||
await page.goto('/errorClick'); | ||
|
||
const [_, events] = await Promise.all([ | ||
page.click('button'), | ||
getMultipleSentryEnvelopeRequests<Event>(page, 1, { envelopeType: 'event' }), | ||
]); | ||
|
||
expect(events[0].exception?.values?.[0]).toMatchObject({ | ||
type: 'Error', | ||
value: 'Sentry Frontend Error', | ||
}); | ||
}); |
19 changes: 0 additions & 19 deletions
19
packages/nextjs/test/integration/test/client/errorGlobal.js
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
packages/nextjs/test/integration/test/client/errorGlobal.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,12 @@ | ||
import { getMultipleSentryEnvelopeRequests } from './utils/helpers'; | ||
import { test, expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
test('should capture a globally triggered event', async ({ page }) => { | ||
const event = await getMultipleSentryEnvelopeRequests<Event>(page, 1, { url: '/crashed', envelopeType: 'event' }); | ||
|
||
expect(event[0].exception?.values?.[0]).toMatchObject({ | ||
type: 'Error', | ||
value: 'Crashed', | ||
}); | ||
}); |
11 changes: 0 additions & 11 deletions
11
packages/nextjs/test/integration/test/client/faultyAppGetInitialPropsConfiguration.js
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
packages/nextjs/test/integration/test/client/faultyAppGetInitialPropsConfiguration.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,13 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
// This test verifies that a faulty configuration of `getInitialProps` in `_app` will not cause our | ||
// auto - wrapping / instrumentation to throw an error. | ||
// See `_app.tsx` for more information. | ||
|
||
test('should not fail auto-wrapping when `getInitialProps` configuration is faulty.', async ({ page }) => { | ||
await page.goto('/faultyAppGetInitialProps'); | ||
|
||
const serverErrorText = await page.$('//*[contains(text(), "Internal Server Error")]'); | ||
|
||
expect(serverErrorText).toBeFalsy(); | ||
}); |
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
27 changes: 0 additions & 27 deletions
27
packages/nextjs/test/integration/test/client/sessionCrashed.js
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
packages/nextjs/test/integration/test/client/sessionCrashed.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 { countEnvelopes, getMultipleSentryEnvelopeRequests } from './utils/helpers'; | ||
import { test, expect } from '@playwright/test'; | ||
import { Session } from '@sentry/types'; | ||
|
||
test('should report crashed sessions', async ({ page }) => { | ||
const event = await getMultipleSentryEnvelopeRequests<Session>(page, 2, { url: '/crashed', envelopeType: 'session' }); | ||
|
||
expect(event[0]).toMatchObject({ | ||
init: true, | ||
status: 'ok', | ||
errors: 0, | ||
}); | ||
|
||
expect(event[1]).toMatchObject({ | ||
init: false, | ||
status: 'crashed', | ||
errors: 1, | ||
}); | ||
|
||
expect(await countEnvelopes(page, { url: '/crashed', envelopeType: 'session' })).toBe(2); | ||
}); |
Oops, something went wrong.
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.
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.
Potential race condition
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.
We've done this before with no issues:
sentry-javascript/packages/integration-tests/suites/sessions/update-session/test.ts
Line 11 in 59e51bd
We can adjust this if it is causing flakes.