---
title: "Unit test"
description: "Elysia provides a Elysia.fetch function to easily test your application."
url: "https://next.elysiajs.com/tutorial/features/unit-test/"
---

# Unit test

Elysia provides a **Elysia.fetch** function to easily test your application.

**Elysia.fetch** takes a Web Standard Request, and returns a Response similar to the [browser’s fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).

```typescript
import { Elysia } from 'elysia'

const app = new Elysia()
  .get('/', 'Hello World')

const response = await app.fetch(new Request('http://localhost/'))
console.log(await response.text())
```

This will run a request like an **actual request** (not simulated).

### Test

This allows us to easily test our application without running a server.

Bun Test

```typescript
import { describe, it, expect } from 'bun:test'

import { Elysia } from 'elysia'

describe('Elysia', () => {
  it('should return Hello World', async () => {
    const app = new Elysia().get('/', 'Hello World')

    const response = await app.fetch(new Request('http://localhost/'))
    const text = await response.text()

    expect(text).toBe('Hello World')
  })
})
```

Vitest

```typescript
import { describe, it, expect } from 'vitest'

import { Elysia } from 'elysia'

describe('Elysia', () => {
  it('should return Hello World', async () => {
    const app = new Elysia().get('/', 'Hello World')

    const response = await app.fetch(new Request('http://localhost/'))
    const text = await response.text()

    expect(text).toBe('Hello World')
  })
})
```

Jest

```typescript
import { describe, test, expect } from '@jest/globals'

import { Elysia } from 'elysia'

describe('Elysia', () => {
  test('should return Hello World', async () => {
    const app = new Elysia().get('/', 'Hello World')

    const response = await app.fetch(new Request('http://localhost/'))
    const text = await response.text()

    expect(text).toBe('Hello World')
  })
})
```

See [Unit test](/patterns/unit-test/).

## Assignment

Let’s click the  icon in the preview to see how’s the request is logged.
