-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(hono): Use generic Hono type in Bun/Node #21060
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
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
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
80 changes: 80 additions & 0 deletions
80
dev-packages/e2e-tests/test-applications/hono-4/tests/basepath-and-late-routes.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,80 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { waitForTransaction } from '@sentry-internal/test-utils'; | ||
| import { APP_NAME } from './constants'; | ||
|
|
||
| test.describe('basePath with sub-app routes', () => { | ||
| test('traces GET on a sub-app mounted via .basePath().route()', async ({ baseURL }) => { | ||
| const transactionPromise = waitForTransaction(APP_NAME, event => { | ||
| return event.contexts?.trace?.op === 'http.server' && event.transaction === 'GET /test-basepath/v1/users'; | ||
| }); | ||
|
|
||
| const response = await fetch(`${baseURL}/test-basepath/v1/users`); | ||
| expect(response.status).toBe(200); | ||
|
|
||
| const body = await response.json(); | ||
| expect(body).toEqual({ users: [{ id: 1, name: 'Alice' }] }); | ||
|
|
||
| const transaction = await transactionPromise; | ||
| expect(transaction.transaction).toBe('GET /test-basepath/v1/users'); | ||
| expect(transaction.contexts?.trace?.op).toBe('http.server'); | ||
| }); | ||
|
|
||
| test('traces parameterized route under .basePath().route()', async ({ baseURL }) => { | ||
| const transactionPromise = waitForTransaction(APP_NAME, event => { | ||
| return event.contexts?.trace?.op === 'http.server' && event.transaction === 'GET /test-basepath/v1/users/:userId'; | ||
| }); | ||
|
|
||
| const response = await fetch(`${baseURL}/test-basepath/v1/users/42`); | ||
| expect(response.status).toBe(200); | ||
|
|
||
| const body = await response.json(); | ||
| expect(body).toEqual({ userId: '42' }); | ||
|
|
||
| const transaction = await transactionPromise; | ||
| expect(transaction.transaction).toBe('GET /test-basepath/v1/users/:userId'); | ||
| expect(transaction.contexts?.trace?.op).toBe('http.server'); | ||
| }); | ||
| }); | ||
|
|
||
| // TODO: this test is currently skipped because we do not yet support middleware registered on new instances (e.g. here via .basePath(..).use(...)). | ||
| test.skip('.basePath() middleware instrumentation', () => { | ||
| test('creates middleware span for .use() on .basePath() clone', async ({ baseURL }) => { | ||
| const transactionPromise = waitForTransaction(APP_NAME, event => { | ||
| return event.contexts?.trace?.op === 'http.server' && event.transaction === 'GET /test-basepath-mw/hello'; | ||
| }); | ||
|
|
||
| const response = await fetch(`${baseURL}/test-basepath-mw/hello`); | ||
| expect(response.status).toBe(200); | ||
|
|
||
| const body = await response.json(); | ||
| expect(body).toEqual({ greeting: 'world' }); | ||
|
|
||
| const transaction = await transactionPromise; | ||
| expect(transaction.transaction).toBe('GET /test-basepath-mw/hello'); | ||
|
|
||
| const spans = transaction.spans || []; | ||
| const middlewareSpan = spans.find( | ||
| (span: { description?: string; op?: string }) => | ||
| span.op === 'middleware.hono' && span.description === 'basepathMiddleware', | ||
| ); | ||
|
|
||
| expect(middlewareSpan).toBeDefined(); | ||
| expect(middlewareSpan?.origin).toBe('auto.middleware.hono'); | ||
| }); | ||
| }); | ||
|
|
||
| test('traces .get() route registered after .basePath()/.route() chains', async ({ baseURL }) => { | ||
| const transactionPromise = waitForTransaction(APP_NAME, event => { | ||
| return event.contexts?.trace?.op === 'http.server' && event.transaction === 'GET /test-late-get'; | ||
| }); | ||
|
|
||
| const response = await fetch(`${baseURL}/test-late-get`); | ||
| expect(response.status).toBe(200); | ||
|
|
||
| const body = await response.json(); | ||
| expect(body).toEqual({ registered: 'after-chains' }); | ||
|
|
||
| const transaction = await transactionPromise; | ||
| expect(transaction.transaction).toBe('GET /test-late-get'); | ||
| expect(transaction.contexts?.trace?.op).toBe('http.server'); | ||
| }); |
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
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.
Uh oh!
There was an error while loading. Please reload this page.