Skip to main content

HTTP Server testing library for Deno inspired by node-supertest-fetch

This package works with Deno
This package works with Deno
JSR Score
58%
Published
a month ago (3.0.0)

superfetch

GitHub Workflow Status Codecov

HTTP Server testing library inspired by node-supertest-fetch.

Example

Basic testing

import { describe, it } from 'jsr:@std/testing/bdd'
import { makeFetch } from 'jsr:@deno-libs/superfetch'

describe('makeFetch', () => {
  it('should work with HTTP handler', async () => {
    const handler = (res) => new Response('Hello World')

    const fetch = makeFetch(s)

    const res = await fetch('/')
    
    res.expect('Hello World')
  })

run()

Full access to Response and port

import { describe, it } from 'jsr:@std/testing/bdd'
import { makeFetch } from 'jsr:@deno-libs/superfetch'

describe('makeFetch', () => {
  it('should work with HTTP handler', async () => {
    const handler = (res) => new Response('Hello World')

    const fetch = makeFetch(s)

    const res = await fetch('/')
    
    res.expect('Hello World')
    console.log(res) // server response object
    console.log(res.port) // port on which the server was listening
  })

run()

Add Package

deno add jsr:@deno-libs/superfetch

Import symbol

import * as superfetch from "@deno-libs/superfetch";

---- OR ----

Import directly with a jsr specifier

import * as superfetch from "jsr:@deno-libs/superfetch";