“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:
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.
6 Replies
I'd guess this happens because it's inside Deno and it doesn't have a real DOM.
Try omitting the submitter argument
It's actually the
form
argumentAccording to MDN https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData
form
should be the DOM element and yeah - Deno doesn't have DOM API supportMDN Web Docs
FormData: FormData() constructor - Web APIs | MDN
The FormData() constructor creates a new FormData object.
@crowlKats any idea how this should work?
we dont accept any arguments to the constructor since we dont have the DOM.
Since the DOM present in the test file us a userspace package, we cant integrate with it.
Thank you for the infos 🙏