Unit Test
According to the Eden Treaty config and the Unit Test pattern, you can pass an Elysia instance directly to Eden Treaty. This allows you to interact with an Elysia server without sending an actual network request.
You can use this pattern to write unit tests that maintain end‑to‑end type safety while also performing type‑level checks all in one place.
// test/index.test.ts
import { describe, expect, it } from 'bun:test'
import { Elysia } from 'elysia'
import { treaty } from '@elysiajs/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
To perform a type‑safety test, simply run tsc on your test folder.
tsc --noEmit test/**/*.ts
This is useful to ensure type integrity for both client and server, especially during migrations.