Issue Tracker Projects - Functional tests not passing

Hello,
I am doing the Issue Tracker Project, I got a problem that I cannot run the test script by 'npm run test ’ as instructed in the project instruction(I uncomment NODE_ENV in .env file). I am using Glitch for this project, and when I run ‘npm run test’ in the terminal, I will get error message like showed below:

I have submit my project , all challenges passed except the last one

Here is a link to my project code:

I would appreciate if anyone can have a look and give me a hint about how to correctly run the test script , or tell me if there is any problem with my functional tests,

Thank you

Welcome, qtang.

Currently, there might be a bug in this challenge. We need to identify what is making the tests so fickle.

As it stands, the freeCodeCamp tests need the NODE_ENV to be equal to test, in order for you to pass the last user story:

app.get('/_api/get-tests', cors(), function(req, res, next){
    console.log(error);
    if(!error && process.env.NODE_ENV === 'test') return next();
    res.json({status: 'unavailable'});
  },

If the environment variable is set correctly, then the app tests should run automatically, on app restart.

Hope this helps.

Thank you for your reply.

I found that even there is this error when running ‘npm run test’ in the Glitch terminal, can also see the test results on the Glitch log.

Now I have fixed all the functional tests based on the logs.

Hey there. I wonder what is this error is created for? In this part of code
let error;
app.get(’/_api/get-tests’, cors(), function(req, res, next){
console.log(error);
if(!error && process.env.NODE_ENV === ‘test’) return next();
res.json({status: ‘unavailable’});
},

I found that the line if(!error && process.env.NODE_ENV === ‘test’) return next(); is the main problem for me to pass Unit and Functional tests on different chalenges (where i always got {status: ‘unavailable’}). But if i just remove the !error from condition, all the tests starts to pass properly. I’m not sure where the problem is.

This is a good question. After looking at it again, I cannot think when it would not be equal to undefined.

This does not make much sense to me. If you do not remove it, do you see any errors in the console?

Well, for me neither actually. But what i found, when i uncomment NODE_ENV=test, i can start tests on Repl.it and it works good, but at the same time i couldn’t pass FCC tests at all, even if i just pass them through before change NODE_ENV. But when i coomen it back, i can pass through FCC tests and cannot pass through Functional tests. And the only way when it works just right is when i remove !error. There somthing happening with api-requests i think, but i don’t know how this error could brake something while its value is always undefined and never changes.

When i uncomment repl have problems too:


And what’s going on FCC:
And if i comment NODE_ENV=test back, i can pass everything but last challenge: