StefanS
Deno6mo ago
7 replies
Stefan

“TypeError: Illegal constructor” error when using FormData

I'm currently experimenting with the Deno test runner and have set up a simple test.

Or at least, I thought I had!

When running the test I get the following error:
./tests/async-forms.test.ts (uncaught error)
error: (in promise) TypeError: Illegal constructor
        return new FormData(form, submitter);
               ^
    at Module.illegalConstructor (ext:deno_webidl/00_webidl.js:1158:9)
    at new FormData (ext:deno_fetch/21_formdata.js:93:14)
    at getFormData (file:///home/pepper/Websites/uncluttered/static/get-form-data.ts:8:9)
    at file:///home/pepper/Websites/uncluttered/tests/async-forms.test.ts:24:18
This error was not caught from a test and caused the test runner to fail on the referenced module.
It most likely originated from a dangling promise, event/timeout handler or top-level code.


This is the file in which the error occurs:
https://codeberg.org/stefanfrede/uncluttered/src/branch/feature/switch-to-deno-test/static/get-form-data.ts

This is the test file:
https://codeberg.org/stefanfrede/uncluttered/src/branch/feature/switch-to-deno-test/tests/async-forms.test.ts

The idea is to test whether my function returns the correct form values.

To be honest, I currently have no idea why this error occurs, so I would be very grateful for any suggestions on how to solve it.
Was this page helpful?