Personal Library tests works on Replit, but "expected 404 to equal 200" problem on local

Tell us what’s happening:
I can pass all the tests using Replit, however i can’t pass functional_tests on local. it keeps giving me the error :

Uncaught AssertionError: expected 404 to equal 200
      + expected - actual


I inserted a “console.log(req)” into some of my routes in api.js. And I realized functional_tests are not hitting them. I moved my code into Replit, and it worked. I’ve completed and passed the challenge 100%. I had pushed it then I pulled my work from git into my VS Code enviroment. I touched nothing. The work passing on the Replit, still gives the same error on local. The same error for all the tests :

Why functional_tests are not hitting the routes correctly on local? Everything is same.
Thanks in advance.
Your project link(s)


githubLink: GitHub - 0x4Bh/boilerplate-project-library-FORK: A boilerplate for a freeCodeCamp project.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Quality Assurance Projects - Personal Library

Link to the challenge:

this link is not working for me!!

Now, my Replit doesn’t work :confounded:
I switched off “NODE_ENV=test”, and it’s working but this time no functional tests.

The current situation is:
If I make “NODE_ENV=test”, my Replit app doesn’t answer to even GET ‘/’ request.
If I remove “NODE_ENV=test”, then the Replit app works but no functional_tests as you can guess.

The issue I have is that the project link you posted doesn’t appear to exist on replit.

The Replit link on my 1st post was auto-created by FCC Forum. It changed the “fork” to lowercase. When you capitalize “fork”, the link works.

Ok, thanks, that works.
One point, which may be irrelevant to the issue you’re having, is that you have a sample.env file. In replit, you should store your environment variables in your secrets tab and ditch the sample.env file.
If you want to stop tests from running, it’s easier just to change the value of NODE_ENV to something different (e.g. testicles).
I’ll have a look and see if I can spot anything else which might be causing you issues, but change that first and see if it makes any difference.

Do you have your mongoDB URI stored in your secrets tab too?

Yes, I have created it as “DB”

Yeah, I didn’t delete sample.env but I have .env on local and secrets on Replit.

lets read from instructions

  1. In your .env file set NODE_ENV to test, without quotes

and in your attempt you added a file named “sample.env”, why? where instructions mention to use “.env” file

try address that change and see if that resolves it, happy learning :slight_smile:

I did it, I did it at the beginning. sample.env is irrelevant, nothing is using it, it just stays there. I have .env on my local environment and I have “secrets” in Replit.

Also, without .env file which has the DB string, nothing would work. My app passes everything except the functional_tests. Functional tests are not hitting the routes of my api.js.

“env” file is named as “only” .env unlike any other “filename” which requires both “filename and extension”

The sample.env file is provided in the boilerplate.

ohh, thats interesting!! did you try to change that file name to only “.env” and try it out?

Yes, I did it. I do it all the time. You don’t see it because it’s in .gitignore. It’s “.env” having DB=… and NODE_ENV=test. It is referenced in the source code as “process.env.key_name”. I’m saying you my app is passing all the tests, but the last test(functional_tests). It wouldn’t pass those tests if I had no DB string in .env file.

okay…that makes sense now, let me look into it then, is it under “tests” folder?

app seems to be functioning, i tried “deleting” a book and it did delete though it stays on “screen” until refresh

none of those are “passing” or a “specific” test is failing from that file, or just “delete” api test is failing?

Yes, functional_tests is under the test folder.