Eden Test
Using Eden, we can create an integration test with end-to-end type safety and auto-completion.
Using Eden Treaty to create tests by irvilerodrigues on Twitter
Setup
We can use Bun test to create tests.
Create test/index.test.ts in the root of project directory with the following:
typescript
// test/index.test.ts
import { describe, expect, it } from 'bun:test'
import { edenTreaty } from '@elysiajs/eden'
const app = new Elysia()
.get('/', () => 'hi')
.listen(3000)
const api = edenTreaty<typeof app>('http://localhost:3000')
describe('Elysia', () => {
it('return a response', async () => {
const { data } = await api.get()
expect(data).toBe('hi')
})
})
Then we can perform tests by running bun test
bash
bun test
This allows us to perform integration tests programmatically instead of manual fetch while supporting type checking automatically.
Contributors
