เนื้อหานี้ยังไม่ถูกแปลเป็นภาษาไทย
เนื้อหานี้ยังไม่ถูกแปลเป็นภาษาไทย
Unit test
According to Eden Treaty config and Unit Test, we may pass an Elysia instance to Eden Treaty directly to interact with the Elysia server directly without sending a network request.
We may use this pattern to create a unit test with end-to-end type safety and type-level tests all at once.
import { describe, expect, it } from 'bun:test'import { Elysia } from 'elysia'import { treaty } from '@elysia/eden'
const app = new Elysia().get('/hello', 'hi')const api = treaty(app)
describe('Elysia', () => { it('returns a response', async () => { const { data } = await api.hello.get()
expect(data).toBe('hi')
})})Type safety test
Section titled “Type safety test”Include your test folder in tsconfig.json, then run TypeScript with the project’s compiler options.
bunx tsc --noEmitThis is useful to ensure type integrity for both client and server, especially during migrations.