From 12484c6645c62a36b6824bf9271130b924b9185f Mon Sep 17 00:00:00 2001 From: AgoniJJ <96982150+AgoniJJ@users.noreply.github.com> Date: Tue, 24 Nov 2026 13:38:11 +0800 Subject: [PATCH 1/2] test: add Vitest unit test coverage for Cron, Stripe, Stats and WebSocket plugins Covers four previously untested plugins with behavior-focused unit tests: - Cron: cron parsing utils, alarm scheduling across tasks, active-status slot padding, callback dispatch incl. listener failure paths - Stripe: constructor validation, unsubscribe flow incl. Stripe API error handling, webhook event handling (deleted / checkout / unknown / malformed) - Stats: admin role gate and statistics + plugin registry merge - WebSocket: prefix config, upgrade rejection, 101 upgrade handshake and query message routing over the server socket --- plugins/cron/index.test.ts | 286 ++++++++++++++++++++++++++++++++ plugins/stats/index.test.ts | 116 +++++++++++++ plugins/stripe/index.test.ts | 266 +++++++++++++++++++++++++++++ plugins/websocket/index.test.ts | 232 ++++++++++++++++++++++++++ vitest.config.ts | 8 + 5 files changed, 908 insertions(+) create mode 100644 plugins/cron/index.test.ts create mode 100644 plugins/stats/index.test.ts create mode 100644 plugins/stripe/index.test.ts create mode 100644 plugins/websocket/index.test.ts diff --git a/plugins/cron/index.test.ts b/plugins/cron/index.test.ts new file mode 100644 index 0000000..600eb91 --- /dev/null +++ b/plugins/cron/index.test.ts @@ -0,0 +1,286 @@ +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' +import { CronPlugin } from './index' +import { getNextExecutionTime } from './utils' +import { StarbaseApp } from '../../src/handler' +import { DataSource, QueryResult } from '../../src/types' + +const NOW = new Date('2026-06-01T12:00:00Z').getTime() + +describe('cron utils - getNextExecutionTime', () => { + it('should return the next matching minute for a cron expression', () => { + const next = getNextExecutionTime('* * * * *', NOW) + expect(next).toBe(NOW + 60 * 1000) + }) + + it('should return a time strictly in the future', () => { + const next = getNextExecutionTime('0 0 * * *', NOW) + expect(next).toBeGreaterThan(NOW) + }) + + it('should reject an invalid cron expression', () => { + expect(() => getNextExecutionTime('not a cron', NOW)).toThrow() + }) +}) + +function createMockDataSource(tasks: QueryResult[] = []) { + return { + rpc: { + executeQuery: vi.fn().mockResolvedValue(tasks), + setAlarm: vi.fn().mockResolvedValue(undefined), + }, + } as unknown as DataSource +} + +type RegisteredHandler = (...args: any[]) => Promise + +function createMockApp(dataSource?: DataSource) { + const handlers: Record = {} + const middlewares: RegisteredHandler[] = [] + const context = { + get: vi.fn((key: string) => + key === 'dataSource' ? dataSource : undefined + ), + } + + const app = { + use: vi.fn((middleware: RegisteredHandler) => { + middlewares.push(middleware) + }), + post: vi.fn((path: string, handler: RegisteredHandler) => { + handlers[path] = handlers[path] || [] + handlers[path].push(handler) + }), + get: vi.fn((path: string, handler: RegisteredHandler) => { + handlers[path] = handlers[path] || [] + handlers[path].push(handler) + }), + } as unknown as StarbaseApp + + return { app, handlers, middlewares, context } +} + +async function runMiddlewares(plugin: CronPlugin, app: ReturnType) { + await plugin.register(app.app as StarbaseApp) + for (const middleware of app.middlewares) { + await middleware(app.context as any, vi.fn()) + } +} + +afterEach(() => { + vi.useRealTimers() +}) + +describe('CronPlugin - Initialization', () => { + beforeEach(() => { + vi.useFakeTimers() + vi.setSystemTime(NOW) + }) + it('should initialize with the cron prefix and require auth', () => { + const plugin = new CronPlugin() + expect(plugin.pathPrefix).toBe('/cron') + expect(plugin.opts.requiresAuth).toBe(true) + }) +}) + +describe('CronPlugin - register()', () => { + beforeEach(() => { + vi.useFakeTimers() + vi.setSystemTime(NOW) + }) + + it('should create the tmp_cron_tasks table when a data source is available', async () => { + const dataSource = createMockDataSource() + const app = createMockApp(dataSource) + + await runMiddlewares(new CronPlugin(), app) + + expect(dataSource.rpc.executeQuery).toHaveBeenCalledWith({ + sql: expect.stringContaining('CREATE TABLE IF NOT EXISTS tmp_cron_tasks'), + params: [], + }) + }) + + it('should not touch the data source when none is provided', async () => { + const plugin = new CronPlugin() + const app = createMockApp(undefined) + await plugin.register(app.app as StarbaseApp) + + for (const middleware of app.middlewares) { + await expect(middleware(app.context as any, vi.fn())).resolves.toBeUndefined() + } + }) + + it('should schedule an alarm at the earliest next execution time across tasks', async () => { + // A task firing at the next minute boundary, and one firing daily at midnight. + const soon = getNextExecutionTime('* * * * *', NOW) + const daily = getNextExecutionTime('0 0 * * *', NOW) + expect(soon).toBeLessThan(daily) + + const dataSource = createMockDataSource([ + { name: 'every-minute', cron_tab: '* * * * *', payload: '{}' }, + { name: 'daily', cron_tab: '0 0 * * *', payload: '{}' }, + ] as QueryResult[]) + const app = createMockApp(dataSource) + + await runMiddlewares(new CronPlugin(), app) + + expect(dataSource.rpc.setAlarm).toHaveBeenCalledTimes(1) + expect(dataSource.rpc.setAlarm).toHaveBeenCalledWith(soon) + }) + + it('should pad the active-status update to exactly ten task name slots', async () => { + const dataSource = createMockDataSource([ + { name: 'only-task', cron_tab: '* * * * *', payload: '{}' }, + ] as QueryResult[]) + const app = createMockApp(dataSource) + + await runMiddlewares(new CronPlugin(), app) + + const updateCall = dataSource.rpc.executeQuery.mock.calls.find( + ([{ sql }]: any) => sql.includes('UPDATE tmp_cron_tasks') + ) + expect(updateCall).toBeDefined() + expect(updateCall[0].params).toHaveLength(10) + expect(updateCall[0].params[0]).toBe('only-task') + expect(updateCall[0].params.slice(1)).toEqual(Array(9).fill(null)) + }) + + it('should not set an alarm when no tasks exist', async () => { + const dataSource = createMockDataSource([]) + const app = createMockApp(dataSource) + + await runMiddlewares(new CronPlugin(), app) + + expect(dataSource.rpc.setAlarm).not.toHaveBeenCalled() + }) +}) + +describe('CronPlugin - addEvent()', () => { + beforeEach(() => { + vi.useFakeTimers() + vi.setSystemTime(NOW) + }) + + it('should insert a task and reschedule the alarm', async () => { + const dataSource = createMockDataSource() + const plugin = new CronPlugin() + const app = createMockApp(dataSource) + await runMiddlewares(plugin, app) + // After registration, return an existing task for GET_TASKS so the + // reschedule pass has something to schedule an alarm for. + dataSource.rpc.executeQuery.mockResolvedValue([ + { name: 'my-task', cron_tab: '* * * * *', payload: '{}' }, + ]) + + await plugin.addEvent('* * * * *', 'my-task', { foo: 'bar' }, 'https://callback.host') + + expect(dataSource.rpc.executeQuery).toHaveBeenCalledWith({ + sql: expect.stringContaining('INSERT OR REPLACE INTO tmp_cron_tasks'), + params: ['my-task', '* * * * *', '{"foo":"bar"}', 'https://callback.host'], + }) + expect(dataSource.rpc.setAlarm).toHaveBeenCalled() + }) + + it('should reject adding events before the plugin has a data source', async () => { + const plugin = new CronPlugin() + await expect( + plugin.addEvent('* * * * *', 'my-task', {}, 'https://callback.host') + ).rejects.toThrow('CronPlugin not properly initialized') + }) +}) + +describe('CronPlugin - callback route and event callbacks', () => { + it('should notify every registered listener with each payload element', async () => { + const plugin = new CronPlugin() + const app = createMockApp(createMockDataSource()) + await plugin.register(app.app as StarbaseApp) + + const first = vi.fn() + const second = vi.fn() + plugin.onEvent(first) + plugin.onEvent(second) + + const handler = app.handlers['/cron/callback'][0] + const response = await handler({ + req: { + json: vi.fn().mockResolvedValue([ + { name: 'task-a', cron_tab: '* * * * *', payload: { n: 1 } }, + { name: 'task-b', cron_tab: '* * * * *', payload: { n: 2 } }, + ]), + }, + }) + + expect(first).toHaveBeenCalledTimes(2) + expect(second).toHaveBeenCalledTimes(2) + expect(first).toHaveBeenNthCalledWith(1, { + name: 'task-a', + cron_tab: '* * * * *', + payload: { n: 1 }, + }) + const body = await response.json() + expect(body.result).toEqual({ success: true }) + }) + + it('should keep dispatching when one listener throws', async () => { + const plugin = new CronPlugin() + const app = createMockApp(createMockDataSource()) + await plugin.register(app.app as StarbaseApp) + + // Listener errors surface as rejections of the wrapped async callback; + // capture the unhandled rejection instead of letting it fail the run. + const unhandled: unknown[] = [] + const rejectionHandler = (reason: unknown) => unhandled.push(reason) + process.on('unhandledRejection', rejectionHandler) + + const failing = vi.fn(() => { + throw new Error('listener exploded') + }) + const healthy = vi.fn() + plugin.onEvent(failing as any) + plugin.onEvent(healthy) + + try { + const handler = app.handlers['/cron/callback'][0] + const response = await handler({ + req: { + json: vi.fn().mockResolvedValue([ + { name: 'task-a', cron_tab: '* * * * *', payload: {} }, + ]), + }, + }) + + expect(failing).toHaveBeenCalledTimes(1) + expect(healthy).toHaveBeenCalledTimes(1) + expect(response.status).toBe(200) + await new Promise((resolve) => setImmediate(resolve)) + expect( + unhandled.some( + (e) => e instanceof Error && e.message === 'listener exploded' + ) + ).toBe(true) + } finally { + process.off('unhandledRejection', rejectionHandler) + } + }) + + it('should wrap async listeners with the execution context via waitUntil', async () => { + const plugin = new CronPlugin() + const app = createMockApp(createMockDataSource()) + await plugin.register(app.app as StarbaseApp) + + const waitUntil = vi.fn() + const asyncListener = vi.fn().mockResolvedValue(undefined) + plugin.onEvent(asyncListener, { waitUntil } as any) + + const handler = app.handlers['/cron/callback'][0] + await handler({ + req: { + json: vi.fn().mockResolvedValue([ + { name: 'task-a', cron_tab: '* * * * *', payload: {} }, + ]), + }, + }) + + expect(waitUntil).toHaveBeenCalledTimes(1) + }) +}) diff --git a/plugins/stats/index.test.ts b/plugins/stats/index.test.ts new file mode 100644 index 0000000..d86c7e1 --- /dev/null +++ b/plugins/stats/index.test.ts @@ -0,0 +1,116 @@ +import { describe, it, expect, vi, beforeEach } from 'vitest' +import { StatsPlugin } from './index' +import { StarbaseApp } from '../../src/handler' + +type RegisteredHandler = (...args: any[]) => Promise + +function createMockApp() { + const getHandlers: Record = {} + const middlewares: RegisteredHandler[] = [] + const app = { + use: vi.fn((middleware: RegisteredHandler) => { + middlewares.push(middleware) + }), + get: vi.fn((path: string, handler: RegisteredHandler) => { + getHandlers[path] = getHandlers[path] || [] + getHandlers[path].push(handler) + }), + } as unknown as StarbaseApp + return { app, getHandlers, middlewares } +} + +function createMockContext(config: { role?: string } | undefined) { + const dataSource = { + rpc: { + getStatistics: vi + .fn() + .mockResolvedValue({ totalQueries: 42, activeSessions: 3 }), + executeQuery: vi.fn(), + }, + registry: { + currentPlugins: vi + .fn() + .mockReturnValue(['starbasedb:cron', 'starbasedb:stats']), + }, + } + return { + context: { + get: vi.fn((key: string) => { + if (key === 'config') return config + if (key === 'dataSource') return dataSource + return undefined + }), + } as any, + dataSource, + } +} + +async function registerPlugin(context: any) { + const plugin = new StatsPlugin() + const { app, getHandlers, middlewares } = createMockApp() + await plugin.register(app) + for (const middleware of middlewares) { + await middleware(context, vi.fn()) + } + return { plugin, getHandlers } +} + +describe('StatsPlugin - Initialization', () => { + it('should register under the internal stats prefix and require auth', () => { + const plugin = new StatsPlugin() + expect(plugin.prefix).toBe('/_internal/stats') + expect(plugin.opts.requiresAuth).toBe(true) + }) +}) + +describe('StatsPlugin - register()', () => { + it('should capture config and data source from the request context', async () => { + const { context } = createMockContext({ role: 'admin' }) + const { getHandlers } = await registerPlugin(context) + + expect(context.get).toHaveBeenCalledWith('config') + expect(context.get).toHaveBeenCalledWith('dataSource') + expect(getHandlers['/_internal/stats']).toHaveLength(1) + }) +}) + +describe('StatsPlugin - GET /_internal/stats', () => { + it('should return 400 for non-admin roles', async () => { + const { context, dataSource } = createMockContext({ role: 'user' }) + const { getHandlers } = await registerPlugin(context) + + const response = await getHandlers['/_internal/stats'][0](context) + + expect(response.status).toBe(400) + expect(await response.text()).toBe('Unauthorized request') + expect(dataSource.rpc.getStatistics).not.toHaveBeenCalled() + }) + + it('should return 400 when no config is present', async () => { + const { context } = createMockContext(undefined) + const { getHandlers } = await registerPlugin(context) + + const response = await getHandlers['/_internal/stats'][0](context) + + expect(response.status).toBe(400) + }) + + it('should merge database statistics with the active plugin registry', async () => { + const { context, dataSource } = createMockContext({ role: 'admin' }) + const { getHandlers } = await registerPlugin(context) + + const response = await getHandlers['/_internal/stats'][0](context) + + expect(response.status).toBe(200) + expect(dataSource.rpc.getStatistics).toHaveBeenCalledTimes(1) + expect(dataSource.registry.currentPlugins).toHaveBeenCalledTimes(1) + + const body = await response.json() + expect(body.result).toEqual({ + totalQueries: 42, + activeSessions: 3, + plugins: ['starbasedb:cron', 'starbasedb:stats'], + }) + expect(body.error).toBeUndefined() + }) +}) diff --git a/plugins/stripe/index.test.ts b/plugins/stripe/index.test.ts new file mode 100644 index 0000000..622447e --- /dev/null +++ b/plugins/stripe/index.test.ts @@ -0,0 +1,266 @@ +import { describe, it, expect, vi, beforeEach } from 'vitest' +import { StripeSubscriptionPlugin } from './index' +import { StarbaseApp } from '../../src/handler' + +function createMockContext(dataSource?: any, body?: string) { + return { + get: vi.fn((key: string) => + key === 'dataSource' ? dataSource : undefined + ), + req: { + json: vi.fn().mockResolvedValue({}), + text: vi.fn().mockResolvedValue(body ?? ''), + }, + } as any +} + +type RegisteredHandler = (...args: any[]) => Promise + +function createMockApp() { + const handlers: Record = {} + const middlewares: RegisteredHandler[] = [] + const app = { + use: vi.fn((middleware: RegisteredHandler) => { + middlewares.push(middleware) + }), + post: vi.fn((path: string, handler: RegisteredHandler) => { + handlers[path] = handlers[path] || [] + handlers[path].push(handler) + }), + } as unknown as StarbaseApp + return { app, handlers, middlewares } +} + +function createMockDataSource(subscriptions: any[] = []) { + return { + rpc: { + executeQuery: vi.fn().mockResolvedValue(subscriptions), + }, + } +} + +async function registerPlugin(opts?: { dataSource?: any }) { + const plugin = new StripeSubscriptionPlugin({ + stripeSecretKey: 'sk_test_placeholder', + stripeWebhookSecret: 'whsec_placeholder', + }) + const { app, handlers, middlewares } = createMockApp() + await plugin.register(app) + for (const middleware of middlewares) { + await middleware(createMockContext(opts?.dataSource), vi.fn()) + } + return { plugin, handlers } +} + +describe('StripeSubscriptionPlugin - Initialization', () => { + it('should require a Stripe secret key', () => { + expect( + () => new StripeSubscriptionPlugin() + ).toThrow('Stripe API key is required for this plugin.') + }) + + it('should register under the /stripe prefix with auth disabled for webhooks', async () => { + const { plugin, handlers } = await registerPlugin() + expect(plugin.pathPrefix).toBe('/stripe') + expect(plugin.opts.requiresAuth).toBe(false) + expect(Object.keys(handlers)).toEqual( + expect.arrayContaining([ + '/stripe/subscribe', + '/stripe/unsubscribe', + '/stripe/webhook', + ]) + ) + }) +}) + +describe('StripeSubscriptionPlugin - unsubscribe route', () => { + it('should reject requests missing userId with 400', async () => { + const { handlers } = await registerPlugin() + const handler = handlers['/stripe/unsubscribe'][0] + + const response = await handler({ + get: vi.fn(), + req: { json: vi.fn().mockResolvedValue({}) }, + } as any) + + expect(response.status).toBe(400) + expect(await response.text()).toBe('Missing required fields: userId') + }) + + it('should return 404 when the user has no active subscription', async () => { + const dataSource = createMockDataSource([]) + const { handlers } = await registerPlugin({ dataSource }) + const handler = handlers['/stripe/unsubscribe'][0] + + const response = await handler({ + get: vi.fn((key: string) => + key === 'dataSource' ? dataSource : undefined + ), + req: { json: vi.fn().mockResolvedValue({ userId: 'user-1' }) }, + } as any) + + expect(response.status).toBe(404) + expect(await response.text()).toBe('User not found') + }) + + it('should cancel the Stripe subscription and mark it deleted in SQLite', async () => { + const dataSource = createMockDataSource([ + { stripe_subscription_id: 'sub_123' }, + ]) + const { handlers } = await registerPlugin({ dataSource }) + const handler = handlers['/stripe/unsubscribe'][0] + + const fetchMock = vi + .fn() + // cancelSubscription -> POST /v1/subscriptions/sub_123 + .mockResolvedValue( + new Response(JSON.stringify({ id: 'sub_123', status: 'canceled' }), { + status: 200, + }) + ) + vi.stubGlobal('fetch', fetchMock) + + const response = await handler({ + get: vi.fn((key: string) => + key === 'dataSource' ? dataSource : undefined + ), + req: { json: vi.fn().mockResolvedValue({ userId: 'user-1' }) }, + } as any) + + expect(response.status).toBe(200) + const body = await response.json() + expect(body.result).toEqual({ success: true }) + + // cancelSubscription -> DELETE /v1/subscriptions/sub_123 + expect(fetchMock).toHaveBeenCalledWith( + 'https://api.stripe.com/v1/subscriptions/sub_123', + expect.objectContaining({ method: 'DELETE' }) + ) + expect(fetchMock.mock.calls[0][1].headers.Authorization).toBe( + 'Bearer sk_test_placeholder' + ) + + expect(dataSource.rpc.executeQuery).toHaveBeenCalledWith({ + sql: expect.stringContaining('SET deleted_at = CURRENT_TIMESTAMP'), + params: ['user-1'], + }) + + vi.unstubAllGlobals() + }) + + it('should surface Stripe API failures as a 500 response', async () => { + const dataSource = createMockDataSource([ + { stripe_subscription_id: 'sub_123' }, + ]) + const { handlers } = await registerPlugin({ dataSource }) + const handler = handlers['/stripe/unsubscribe'][0] + + vi.stubGlobal( + 'fetch', + vi.fn().mockResolvedValue( + new Response(JSON.stringify({ error: { message: 'nope' } }), { + status: 402, + statusText: 'Payment Required', + }) + ) + ) + + const response = await handler({ + get: vi.fn((key: string) => + key === 'dataSource' ? dataSource : undefined + ), + req: { json: vi.fn().mockResolvedValue({ userId: 'user-1' }) }, + } as any) + + expect(response.status).toBe(500) + const body = await response.json() + expect(body.error).toContain('Failed to subscribe') + + vi.unstubAllGlobals() + }) +}) + +describe('StripeSubscriptionPlugin - webhook route', () => { + let dataSource: ReturnType + + beforeEach(async () => { + dataSource = createMockDataSource() + await registerPlugin({ dataSource }) + // Registration itself runs a CREATE TABLE query; reset call counts so + // webhook assertions only see queries triggered by the handler. + dataSource.rpc.executeQuery.mockClear() + }) + + const runWebhook = async (event: unknown) => { + const { handlers } = await registerPlugin({ dataSource }) + dataSource.rpc.executeQuery.mockClear() + const handler = handlers['/stripe/webhook'][0] + return handler(createMockContext(dataSource, JSON.stringify(event))) + } + + it('should mark the subscription deleted for customer.subscription.deleted events', async () => { + const response = await runWebhook({ + type: 'customer.subscription.deleted', + data: { object: { id: 'sub_deleted_1' } }, + }) + + expect(response.status).toBe(200) + const body = await response.json() + expect(body.result).toEqual({ success: true }) + expect(dataSource.rpc.executeQuery).toHaveBeenCalledWith({ + sql: expect.stringContaining('WHERE stripe_subscription_id = ?'), + params: ['sub_deleted_1'], + }) + }) + + it('should upsert subscription data for completed checkout sessions', async () => { + const response = await runWebhook({ + type: 'checkout.session.completed', + data: { + object: { + subscription: 'sub_new_1', + client_reference_id: 'user-42', + customer: 'cus_77', + }, + }, + }) + + expect(response.status).toBe(200) + expect(dataSource.rpc.executeQuery).toHaveBeenCalledWith({ + sql: expect.stringContaining('ON CONFLICT(user_id) DO UPDATE'), + params: ['user-42', 'cus_77', 'sub_new_1'], + }) + }) + + it('should ignore webhook events it does not care about', async () => { + const response = await runWebhook({ + type: 'invoice.paid', + data: { object: { id: 'in_1' } }, + }) + + expect(response.status).toBe(200) + expect(dataSource.rpc.executeQuery).not.toHaveBeenCalled() + }) + + it('should skip completed sessions without a subscription id', async () => { + const response = await runWebhook({ + type: 'checkout.session.completed', + data: { object: { subscription: null } }, + }) + + expect(response.status).toBe(200) + expect(dataSource.rpc.executeQuery).not.toHaveBeenCalled() + }) + + it('should return a 400 error response for malformed JSON bodies', async () => { + const { handlers } = await registerPlugin({ dataSource }) + dataSource.rpc.executeQuery.mockClear() + const handler = handlers['/stripe/webhook'][0] + + const response = await handler(createMockContext(dataSource, '{not-json')) + + expect(response.status).toBe(400) + const body = await response.json() + expect(body.error).toContain('Webhook processing failed') + }) +}) diff --git a/plugins/websocket/index.test.ts b/plugins/websocket/index.test.ts new file mode 100644 index 0000000..d1cf689 --- /dev/null +++ b/plugins/websocket/index.test.ts @@ -0,0 +1,232 @@ +import { describe, it, expect, vi, beforeEach } from 'vitest' +import { WebSocketPlugin } from './index' +import { StarbaseApp, StarbaseContext } from '../../src/handler' + +type RegisteredHandler = (...args: any[]) => Response + +function createMockApp() { + const allHandlers: Record = {} + const app = { + all: vi.fn((path: string, handler: RegisteredHandler) => { + allHandlers[path] = allHandlers[path] || [] + allHandlers[path].push(handler) + }), + } as unknown as StarbaseApp + return { app, allHandlers } +} + +function createMockContext(overrides: Record = {}) { + const store: Record = { + config: { role: 'admin' }, + dataSource: { rpc: { executeQuery: vi.fn() } }, + operations: { executeQuery: vi.fn().mockResolvedValue({ rows: [] }) }, + ...overrides, + } + return { + get: vi.fn((key: string) => store[key]), + req: { + header: vi.fn((name: string) => { + if (name === 'upgrade') return store.upgradeHeader + return undefined + }), + }, + } as unknown as StarbaseContext +} + +describe('WebSocketPlugin - Initialization', () => { + it('should default to the /socket prefix', () => { + const plugin = new WebSocketPlugin() + expect(plugin['prefix']).toBe('/socket') + expect(plugin.opts.requiresAuth).toBe(true) + }) + + it('should allow a custom prefix', () => { + const plugin = new WebSocketPlugin({ prefix: '/custom-socket' }) + expect(plugin['prefix']).toBe('/custom-socket') + }) +}) + +describe('WebSocketPlugin - register()', () => { + it('should register an all-methods handler on its prefix', async () => { + const plugin = new WebSocketPlugin({ prefix: '/ws' }) + const { app, allHandlers } = createMockApp() + + await plugin.register(app) + + expect(app.all).toHaveBeenCalledWith('/ws', expect.any(Function)) + expect(allHandlers['/ws']).toHaveLength(1) + }) + + it('should reject requests without a websocket upgrade header', async () => { + const plugin = new WebSocketPlugin() + const { app, allHandlers } = createMockApp() + await plugin.register(app) + + const context = createMockContext({ upgradeHeader: undefined }) + const response = allHandlers['/socket'][0](context) + + expect(response.status).toBe(400) + expect(await response.text()).toBe('Expected upgrade request') + }) + + it('should reject requests with a non-websocket upgrade header', async () => { + const plugin = new WebSocketPlugin() + const { app, allHandlers } = createMockApp() + await plugin.register(app) + + const context = createMockContext({ upgradeHeader: 'h2c' }) + const response = allHandlers['/socket'][0](context) + + expect(response.status).toBe(400) + expect(await response.text()).toBe('Expected upgrade request') + }) + + it('should upgrade valid websocket requests with a 101 response', async () => { + // Cloudflare Workers expose WebSocketPair as a global; stub it for the Node test env. + class FakeWebSocket { + accept = vi.fn() + addEventListener = vi.fn() + send = vi.fn() + } + const [client, server] = [new FakeWebSocket(), new FakeWebSocket()] + ;(globalThis as any).WebSocketPair = class { + constructor() { + return { 0: client, 1: server } + } + } + + // Node's Response constructor rejects status 101, so stub a minimal + // response class that captures what the Workers runtime provides. + const originalResponse = globalThis.Response + class FakeResponse { + status: number + webSocket: unknown + constructor(_body: any, init?: any) { + this.status = init?.status ?? 200 + this.webSocket = init?.webSocket + } + async text() { + return '' + } + } + ;(globalThis as any).Response = FakeResponse + + try { + const plugin = new WebSocketPlugin() + const { app, allHandlers } = createMockApp() + await plugin.register(app) + + const context = createMockContext({ upgradeHeader: 'websocket' }) + const response = allHandlers['/socket'][0](context) as any + + expect(response.status).toBe(101) + expect(response.webSocket).toBe(client) + expect(server.accept).toHaveBeenCalledTimes(1) + } finally { + ;(globalThis as any).Response = originalResponse + delete (globalThis as any).WebSocketPair + } + }) +}) + +describe('WebSocketPlugin - message handling', () => { + it('should execute SQL queries sent as query actions and return the result', async () => { + const executeQuery = vi + .fn() + .mockResolvedValue({ rows: [{ id: 1 }] }) + class FakeWebSocket { + accept = vi.fn() + addEventListener = vi.fn() + send = vi.fn() + } + const [client, server] = [new FakeWebSocket(), new FakeWebSocket()] + ;(globalThis as any).WebSocketPair = class { + constructor() { + return { 0: client, 1: server } + } + } + + const plugin = new WebSocketPlugin() + const connection = plugin.createConnection( + createMockContext({ + operations: { executeQuery }, + }) as any + ) + + expect(connection).toBe(client) + + // Grab the 'message' listener the plugin registered on the server socket. + const messageListener = server.addEventListener.mock.calls.find( + ([event]: any) => event === 'message' + )![1] + + messageListener({ + data: JSON.stringify({ + sql: 'SELECT * FROM users WHERE id = ?', + params: [1], + action: 'query', + }), + }) + + await vi.waitFor(() => { + expect(executeQuery).toHaveBeenCalledWith( + expect.objectContaining({ + sql: 'SELECT * FROM users WHERE id = ?', + params: [1], + isRaw: false, + }) + ) + }) + await vi.waitFor(() => { + expect(server.send).toHaveBeenCalledWith( + JSON.stringify({ rows: [{ id: 1 }] }) + ) + }) + + delete (globalThis as any).WebSocketPair + }) + + it('should ignore messages whose action is not a query', async () => { + const executeQuery = vi.fn() + class FakeWebSocket { + accept = vi.fn() + addEventListener = vi.fn() + send = vi.fn() + } + const [client, server] = [new FakeWebSocket(), new FakeWebSocket()] + ;(globalThis as any).WebSocketPair = class { + constructor() { + return { 0: client, 1: server } + } + } + + const plugin = new WebSocketPlugin() + plugin.createConnection(createMockContext({ operations: { executeQuery } }) as any) + + const messageListener = server.addEventListener.mock.calls.find( + ([event]: any) => event === 'message' + )![1] + + messageListener({ + data: JSON.stringify({ action: 'ping' }), + }) + + // Flush the microtask queue before asserting nothing was executed. + await Promise.resolve() + expect(executeQuery).not.toHaveBeenCalled() + expect(server.send).not.toHaveBeenCalled() + + delete (globalThis as any).WebSocketPair + }) +}) + +describe('WebSocketPlugin - sendMessage()', () => { + it('should forward the message to the given client socket', () => { + const plugin = new WebSocketPlugin() + const client = { send: vi.fn() } as any + + plugin.sendMessage('hello', client) + + expect(client.send).toHaveBeenCalledWith('hello') + }) +}) diff --git a/vitest.config.ts b/vitest.config.ts index 8546114..f0e2cba 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,7 +1,15 @@ import { defineConfig } from 'vitest/config' +import { resolve } from 'path' export default defineConfig({ assetsInclude: ['**/*.sql'], + resolve: { + alias: { + // Allow plugins that import the built package entry (e.g. `../../dist`) + // to be unit tested directly against the TypeScript sources. + [resolve(__dirname, 'dist')]: resolve(__dirname, 'src/index.ts'), + }, + }, test: { coverage: { provider: 'istanbul', From 42f73a2eb68e481247e0feec353df47471a0c8bc Mon Sep 17 00:00:00 2001 From: AgoniJJ <96982150+AgoniJJ@users.noreply.github.com> Date: Tue, 24 Nov 2026 13:39:26 +0800 Subject: [PATCH 2/2] docs: add animated demo of the new plugin test suite running --- docs/demo-vitest-run.svg | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 docs/demo-vitest-run.svg diff --git a/docs/demo-vitest-run.svg b/docs/demo-vitest-run.svg new file mode 100644 index 0000000..c30697d --- /dev/null +++ b/docs/demo-vitest-run.svg @@ -0,0 +1,8 @@ + + + + +starbasedb — vitest run (demo) +Stripe API error: Error: Stripe API call failed: Payment Required. Details: {"error":{"message":"nope"}} at StripeSubscriptionPlugin.callStripeAPI (/root/work/starbasedb/plugins/stripe/index.ts:238:23) at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.ts:160:17 at /root/work/starbasedb/plugins/stripe/index.test.ts:168:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)stderr | plugins/stripe/index.test.ts > StripeSubscriptionPlugin - webhook route > should return a 400 error response for malformed JSON bodiesWebhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at StripeSubscriptionPlugin.callStripeAPI (/root/work/starbasedb/plugins/stripe/index.ts:238:23) at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.ts:160:17 at /root/work/starbasedb/plugins/stripe/index.test.ts:168:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)stderr | plugins/stripe/index.test.ts > StripeSubscriptionPlugin - webhook route > should return a 400 error response for malformed JSON bodiesWebhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3) at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.ts:160:17 at /root/work/starbasedb/plugins/stripe/index.test.ts:168:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)stderr | plugins/stripe/index.test.ts > StripeSubscriptionPlugin - webhook route > should return a 400 error response for malformed JSON bodiesWebhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) at /root/work/starbasedb/plugins/stripe/index.ts:160:17 at /root/work/starbasedb/plugins/stripe/index.test.ts:168:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)stderr | plugins/stripe/index.test.ts > StripeSubscriptionPlugin - webhook route > should return a 400 error response for malformed JSON bodiesWebhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) at /root/work/starbasedb/plugins/stripe/index.test.ts:168:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)stderr | plugins/stripe/index.test.ts > StripeSubscriptionPlugin - webhook route > should return a 400 error response for malformed JSON bodiesWebhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)stderr | plugins/stripe/index.test.ts > StripeSubscriptionPlugin - webhook route > should return a 400 error response for malformed JSON bodiesWebhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)stderr | plugins/stripe/index.test.ts > StripeSubscriptionPlugin - webhook route > should return a 400 error response for malformed JSON bodiesWebhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)stderr | plugins/stripe/index.test.ts > StripeSubscriptionPlugin - webhook route > should return a 400 error response for malformed JSON bodiesWebhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)stderr | plugins/stripe/index.test.ts > StripeSubscriptionPlugin - webhook route > should return a 400 error response for malformed JSON bodiesWebhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)stderr | plugins/stripe/index.test.ts > StripeSubscriptionPlugin - webhook route > should return a 400 error response for malformed JSON bodiesWebhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)stderr | plugins/stripe/index.test.ts > StripeSubscriptionPlugin - webhook route > should return a 400 error response for malformed JSON bodiesWebhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14)stderr | plugins/stripe/index.test.ts > StripeSubscriptionPlugin - webhook route > should return a 400 error response for malformed JSON bodiesWebhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)Webhook processing error: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) at JSON.parse (<anonymous>) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) · plugins/stats/index.test.ts (5) at /root/work/starbasedb/plugins/stripe/index.ts:184:36 at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) · plugins/stats/index.test.ts (5) ✓ plugins/cron/index.test.ts (14) at processTicksAndRejections (node:internal/process/task_queues:103:5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) · plugins/stats/index.test.ts (5) ✓ plugins/cron/index.test.ts (14) ✓ plugins/stats/index.test.ts (5) at /root/work/starbasedb/plugins/stripe/index.test.ts:260:26 at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) · plugins/stats/index.test.ts (5) ✓ plugins/cron/index.test.ts (14) ✓ plugins/stats/index.test.ts (5) ✓ plugins/stripe/index.test.ts (11) at file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:533:5 at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) · plugins/stats/index.test.ts (5) ✓ plugins/cron/index.test.ts (14) ✓ plugins/stats/index.test.ts (5) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) at runTest (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1056:11) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) · plugins/stats/index.test.ts (5) ✓ plugins/cron/index.test.ts (14) ✓ plugins/stats/index.test.ts (5) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) Test Files 4 passed (4) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) · plugins/stats/index.test.ts (5) ✓ plugins/cron/index.test.ts (14) ✓ plugins/stats/index.test.ts (5) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) Test Files 4 passed (4) Tests 39 passed (39) at runSuite (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1205:15) at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) · plugins/stats/index.test.ts (5) ✓ plugins/cron/index.test.ts (14) ✓ plugins/stats/index.test.ts (5) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) Test Files 4 passed (4) Tests 39 passed (39) Start at 13:38:27 at runFiles (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1262:5) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) · plugins/stats/index.test.ts (5) ✓ plugins/cron/index.test.ts (14) ✓ plugins/stats/index.test.ts (5) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) Test Files 4 passed (4) Tests 39 passed (39) Start at 13:38:27 Duration 886ms (transform 135ms, setup 0ms, collect 183ms, tests 83ms, environment 1ms, prepare 191ms) at startTests (file:///root/work/starbasedb/node_modules/.pnpm/@vitest+runner@2.1.8/node_modules/@vitest/runner/dist/index.js:1271:3)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) · plugins/stats/index.test.ts (5) ✓ plugins/cron/index.test.ts (14) ✓ plugins/stats/index.test.ts (5) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) Test Files 4 passed (4) Tests 39 passed (39) Start at 13:38:27 Duration 886ms (transform 135ms, setup 0ms, collect 183ms, tests 83ms, environment 1ms, prepare 191ms)[?25h[?25h\[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) · plugins/websocket/index.test.ts (9)[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9)[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l ✓ plugins/cron/index.test.ts (14) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) · plugins/stats/index.test.ts (5) ✓ plugins/cron/index.test.ts (14) ✓ plugins/stats/index.test.ts (5) ✓ plugins/stripe/index.test.ts (11) ✓ plugins/websocket/index.test.ts (9) Test Files 4 passed (4) Tests 39 passed (39) Start at 13:38:27 Duration 886ms (transform 135ms, setup 0ms, collect 183ms, tests 83ms, environment 1ms, prepare 191ms)[?25h[?25h\Script done on 2026-11-24 13:38:28+08:00 [COMMAND_EXIT_CODE="0"] + + \ No newline at end of file