#Testing guidelines for custom API bodyParser config (sizeLimit)?

3 messages · Page 1 of 1 (latest)

reef zodiac
#

We have a frontend error message that appears via a toast when someone tries to upload a pdf file larger than 100MB. That part is working great. But I need to be able to set that file size limitation parameter in the proxy as well. I read that you can simply change your next config to use the following.

const nextConfig = {
  api: {
    bodyParser: {
      sizeLimit: '100mb', // Adjusted to 100mb to prevent large file uploads
    },
  },
}

But how would you actually write a test (jest or Cypress) that would test that a large file is not able to be sent via the proxy to our backend? I'm thinking it would have to be a unit test since the frontend component technically blocks it going to the Nextjs backend at all. I've been struggling with getting this test to work quite right.

Here is my route.test.ts file, keep in mind there are quite a few errors here...
https://gist.github.com/mtander/9d87a5cc782383b89c69e4e763d583fb

Gist

GitHub Gist: instantly share code, notes, and snippets.

warped girderBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

fierce granite