Skip to content

Commit 05fdea1

Browse files
committed
add vite config
1 parent 07d8e67 commit 05fdea1

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

packages/cloudflare/test/handler.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { beforeEach, describe, expect, onTestFinished, test, vi } from 'vitest';
1414
import { CloudflareClient } from '../src/client';
1515
import { withSentry } from '../src/handler';
1616
import { markAsInstrumented } from '../src/instrument';
17+
import * as HonoIntegration from '../src/integrations/hono';
1718

1819
// Custom type for hono-like apps (cloudflare handlers) that include errorHandler and onError
1920
type HonoLikeApp<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown> = ExportedHandler<
@@ -1081,10 +1082,12 @@ describe('withSentry', () => {
10811082
});
10821083

10831084
describe('hono errorHandler', () => {
1084-
test('captures errors handled by the errorHandler', async () => {
1085-
const captureExceptionSpy = vi.spyOn(SentryCore, 'captureException');
1085+
test('calls Hono Integration to handle error captured by the errorHandler', async () => {
10861086
const error = new Error('test hono error');
10871087

1088+
const handleHonoException = vi.fn();
1089+
vi.spyOn(HonoIntegration, 'getHonoIntegration').mockReturnValue({ handleHonoException } as any);
1090+
10881091
const honoApp = {
10891092
fetch(_request, _env, _context) {
10901093
return new Response('test');
@@ -1100,10 +1103,8 @@ describe('withSentry', () => {
11001103
// simulates hono's error handling
11011104
const errorHandlerResponse = honoApp.errorHandler?.(error);
11021105

1103-
expect(captureExceptionSpy).toHaveBeenCalledTimes(1);
1104-
expect(captureExceptionSpy).toHaveBeenLastCalledWith(error, {
1105-
mechanism: { handled: false, type: 'auto.faas.cloudflare.error_handler' },
1106-
});
1106+
expect(handleHonoException).toHaveBeenCalledTimes(1);
1107+
expect(handleHonoException).toHaveBeenLastCalledWith(error);
11071108
expect(errorHandlerResponse?.status).toBe(500);
11081109
});
11091110

packages/cloudflare/test/integrations/hono.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ class FakeClient extends CloudflareClient {
1010
}
1111
}
1212

13-
vi.mock('../../src/debug-build', () => ({
14-
DEBUG_BUILD: true,
15-
__DEBUG_BUILD__: true,
16-
}));
17-
1813
type MockHonoIntegrationType = { handleHonoException: (err: Error) => void };
1914

2015
describe('Hono integration', () => {

packages/cloudflare/vite.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig } from 'vitest/config';
2+
import baseConfig from '../../vite/vite.config';
3+
4+
export default defineConfig({
5+
...baseConfig,
6+
});

0 commit comments

Comments
 (0)