Skip to content

Negative tests for edge functions with Deno #65

Open
@ghost

Description

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

I am trying to write some negative tests for my edge functions, for example:

const testSomeFunction = async () => {
  const { data, error } = await supabaseUser.functions.invoke('some-function', {
    body: {
      userId: 'invalid-id'
    }
  })

  assertEquals(error.message, 'Edge Function returned a non-2xx status code')
  assertEquals(data, null)
}

But when running deno test, the test fails with:

error: Leaking resources:
  - A fetch response body (rid 18) was created during the test, but not consumed during the test. Consume or close the response body `ReadableStream`, e.g `await resp.text()` or `await resp.body.cancel()`.

But I cannot access the response to consume/close/cancel/... it.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create edge function
  2. Create negative test for edge function
  3. Run deno test

Expected behavior

I expect the test to pass, without any leaking resources.

System information

  • OS: Windows 11
  • Version of supabase-js: 2.26.0
  • Version of Node.js: 18.15.0
  • Version of Deno: 1.36.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions