79375522

Date: 2025-01-21 18:21:00
Score: 5
Natty:
Report link

There are many possible reasons you might be getting an Internal Server Error:

  1. The data you are passing to the app in your test is not well formatted or not a valid object (can you provide the src/js/server/fetchMovies.js file, Pages/index)
  2. You manually allowed a security exception in your browser when first visiting your app like for example not using https but http. And then maybe your app doesn't allow Supertest to do the same thing. (does using curl work on your / endpoint? )
  3. Your res.render function might not render html understanded by Supertest

....other errors due to the specificity of the modules you imported

I am not exactly sure of the answer, I hope the above tips head you in the right direction. Please provide as many details as possible.

A good practice in your case when facing such a bug is to decouple all the things you are trying to use all at once and test them individually. This will help you find where your code went wrong.

Some tips to gain visibility:

  1. Do

const linkData = await nav.navLinks();

const moviesData = await api.fetchAllMovies();

outside of the individual routes. You can get the linkData and moviesData in the app. That way your /* routes only have to return html. Only one purpose that you can test and validate that it's not the source of the problem.

  1. Use the same fetchMovies and fetchAllMovies and navlinks in your app and in your tests. If they are different, that might be the reason one way it's running ok and the other it's failing.

  2. Separate your logic functions from your routes and test them one by one by logging in the app what they get.

  3. Test your render function without the logic with test html

  4. Make sure 'Content-Type', /html/ is correct

  5. Change to different modules that do the same thing for you, see what error you get.

Please get back to me at any stage with more information. I would be happy to help further.

Best

Reasons:
  • Whitelisted phrase (-1): in your case
  • RegEx Blacklisted phrase (2.5): can you provide
  • RegEx Blacklisted phrase (2.5): Please provide
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: noswoscar