Information Security Projects - Anonymous Message Board

Tell us what’s happening:
Describe your issue in detail here.

Your project link(s)
solution: https://boilerplate-project-messageboard.mariamawitashen.repl.co

I have been stuck on this project for a while. The ’ DELETE request to /api/replies/{board}’ test is failing. My tests are passing though. Can anyone tell me what I am doing wrong? Thanks in advance.

solution: boilerplate-project-messageboard - Replit

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0

Challenge: Information Security Projects - Anonymous Message Board

Link to the challenge:

Did you mean this to be res.end, or res.send:

res.end("incorrect password");
...
res.end("success");

If functions the way it is, but not sure if .end is not sending the correct content-type perhaps for the tests.

As far as I understand it, the only difference b/n res.end() and res.send is the content-type is text/plain for the first and text/html for the later. I tried them both and the fcc delete test is still not passing.

@cmccormack Hi. I was wondering if you could help me. I am stuck on one fcc test which is deleting a reply. The code passes the tests I have created. But I get “(Test timed out)” for this one fcc test. I have been stuck on this for about a month now. And I couldn’t find any hints on other posts. Could you please have a look at my code and tell me what I am doing wrong?
Cheers :wink:

Just messing around, you’re API seems to work and does what its supposed to.

I ran out of time, but just wanted to point out one thing… probably not causing an issue as your ‘get’ tests pass, but there is a field called ‘__v’ that is returned with your queries. It’s a normal thing from mongoose, but I show you returning it with your responses.

image

Again, just one thing I noticed. If the test is perhaps counting how many fields were present in your response this would cause an issue, but again not sure why that wouldn’t be causing issues in the other test.

And also, I’m curious why you are still using res.end in only your delete requests?

I see you’ve said you tried removing them and it didn’t fix the problem, but why would you put them back? Is there a specific reason you think you should be using res.end instead of res.send? And if you have a logic to it, is there a reason you’re only using it in your delete requests and not any other requests?

If you’re having a difficult to trace problem, I wouldn’t recommend throwing in anything that might cast doubt, especially since the only function of your app that are failing are the only functions in your app that you’re using the res.end in.

Thanks for your feedback. Great tip on staying consistent in my code, I have removed res.end() in the delete request. I have also removed the __v field from my mongoose models, cause you never know. But no dice. I am still not passing the test. This is why it would have been nice to get some hint into exactly how the fcc tests are created. That way we don’t have to guess for weeks. I am simply going to abandon this challenge. I think I have spend enough time on this. Thanks for your help again. You are awesome.

Ugh, I wrote a long explaination regarding some additional problems I had found and how I was able to get testing to pass with your replit… but accidentally overwrote it with an edit while I thought I was just adding an additional comment. Did you happen to see it, or should I rewrite it?

OK, lets try this again:

First, thanks for the kudos, but sadly my mind wouldn’t let it rest.

So, there are ways to kinda tell what the tests are doing. One, this is an open-source site meaning you have access to the source code. It’s probably possible to find the tests in their github, although I’ve never tried and not sure if they frown on that. If you’re using it to troubleshoot a troublesome issue its probably fine, using it as a shortcut to cheat the testing… yeah, not good.

But more easily accessible is console.log(). Outputting to console or debug terminal helps to track down troublesome issues. The FCC tests run your code to get their results, and you can see any outputs of console.log() in your replit console as the tests run.

Funny thing though… I attempted to do this with your code. I forked it so I could edit it, and in the reply delete function I put a header that uses console.log to print out all the inputs at the start of the function, and then right before each res.send I outputed to console the results. This way during the test you get a peak into what was sent to your app, and what the output was, and can help you find weird unexpected issues.

Problem is, when I did this, all output looked fine, and surprisingly all the FCC site tests passed, except for the functional tests part because I hadn’t set the NODE_ENV to ‘test’. All I did was fork your code, had to create a DB .env secret variable for my database, and added the console outputs, and all the tests in FCC site passed.

So to finish I attempted to set NODE_ENV to ‘test’ but I couldn’t get the functional test to run. Looking at your functional tests, I couldn’t make sense of how you had it setup. You had imported all your database schema and hash function stuff, and for some reason the server you’re sending all your Chai server requests with comes from a SECRET variable SERVER??? The classes and all examples I’ve seen just use App for this.

const server = process.env.SERVER;

Without knowning how you setup your server I couldn’t duplicate the tests. I tried testing with App and it gave errors. I also attempted using my own tests, but they also wouldn’t run due to how you have it setup. Never seen anybody set the chai server up as an ENV variable. Getting the functional tests to work would have required a major rewrite on my part it seemed, so I stopped there. I did cheat the functional tests by setting them all to assert.equals(5,5) and with that all tests do pass on FCCs page.

So… in conclusion??? I guess one of two things is causing your repeated failure. One, your Replit is messed up, and forking it into a new replit, and resetting up your ENV variables might fix the problem. Two is its something to do with your complex functional tests that might be messing something up. Without knowing how you set that up I can’t really be sure.

You could try disabling your functional tests by setting NODE_ENVto something besides ‘test’. If your Reply Delete FCC test passes with your functional tests disabled then it might be something with your testing. Otherwise, if even with your testing disabled it fails, then maybe try forking your Replit into a new replit and see if that works.

You could also do what I wasn’t able to as I couldn’t duplicate the error, and use console.log to observe the inputs and what the outputs are during the FCC tests… that might reveal a potential cause for the failures.

Or, could just diregard it like you said, and move on.

I would like to know… what did you set your ENV SECRET variable SERVER to for your Chai testing, and is there a guide or tutorial for doing that that you followed?

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.