[go: up one dir, main page]

Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more

superfetch

GitHub Workflow Status Codecov

Superdeno-like superagent testing library based on Fetch API. Ported from node-supertest-fetch.

Example

import { describe, it, run } from 'https://deno.land/x/tincan/mod.ts'
import { App } from 'https://deno.land/x/tinyhttp@0.1.6/app.ts'
import { makeFetch } from 'https://deno.land/x/superfetch/mod.ts'
import { ServerRequest } from 'https://deno.land/std@0.97.0/http/server.ts'

describe('makeFetch', () => {
  it('should work with tinyhttp', async () => {
    const s = new App().use((req) => req.respond({ body: 'Hello World' }))

    const fetch = makeFetch(s.attach as (req: ServerRequest) => void)

    await fetch('/').expect('Hello World')
  })
})

run()