# Issue Tracker Projects - Functional tests not passing

**URL:** <https://forum.freecodecamp.org/t/issue-tracker-projects-functional-tests-not-passing/435205>\
**Category:** freeCodeCamp Contributors\
**Tags:** contributing\
**Created:** [December 13, 2020, 11:03am UTC](https://forum.freecodecamp.org/t/issue-tracker-projects-functional-tests-not-passing/435205 "2020-12-13T11:03:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![qtang2](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/qtang2/32/184604_2.png) [@qtang2](https://forum.freecodecamp.org/u/qtang2)\
**Post date:** [December 13, 2020, 11:03am UTC](https://forum.freecodecamp.org/t/issue-tracker-projects-functional-tests-not-passing/435205/1 "2020-12-13T11:03:04Z")

</div>

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:

 ![test err](https://global.discourse-cdn.com/freecodecamp/original/3X/9/b/9b1b8031e19c12494b58185cb8e45e48ee25f7c0.png)

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

 ![14 passes](https://global.discourse-cdn.com/freecodecamp/original/3X/a/6/a64b2f8d33e9309829f664b153b7581206dfe2bb.png)

Here is a link to my project code:

> **[Glitch Blog](https://blog.glitch.com)**
>
> The official blog for glitch.com

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

---

<div class="post-metadata">

**Author:** ![Sky020](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sky020/32/128093_2.png) [@Sky020](https://forum.freecodecamp.org/u/Sky020)\
**Post date:** [December 13, 2020, 1:12pm UTC](https://forum.freecodecamp.org/t/issue-tracker-projects-functional-tests-not-passing/435205/2 "2020-12-13T13:12:52Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![qtang2](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/qtang2/32/184604_2.png) [@qtang2](https://forum.freecodecamp.org/u/qtang2)\
**Post date:** [December 14, 2020, 12:21am UTC](https://forum.freecodecamp.org/t/issue-tracker-projects-functional-tests-not-passing/435205/3 "2020-12-14T00:21:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![myjob163](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/myjob163/32/204022_2.png) [@myjob163](https://forum.freecodecamp.org/u/myjob163)\
**Post date:** [March 22, 2021, 6:24am UTC](https://forum.freecodecamp.org/t/issue-tracker-projects-functional-tests-not-passing/435205/4 "2021-03-22T06:24:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Sky020](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sky020/32/128093_2.png) [@Sky020](https://forum.freecodecamp.org/u/Sky020)\
**Post date:** [March 22, 2021, 10:08am UTC](https://forum.freecodecamp.org/t/issue-tracker-projects-functional-tests-not-passing/435205/5 "2021-03-22T10:08:39Z")

</div>

> [@myjob163](#):
>
> what is this error is created for?

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

> [@myjob163](#):
>
> if i just remove the `!error` from condition, all the tests starts to pass properly.

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

---

<div class="post-metadata">

**Author:** ![myjob163](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/myjob163/32/204022_2.png) [@myjob163](https://forum.freecodecamp.org/u/myjob163)\
**Post date:** [March 22, 2021, 10:47am UTC](https://forum.freecodecamp.org/t/issue-tracker-projects-functional-tests-not-passing/435205/6 "2021-03-22T10:47:59Z")

</div>

> [@Sky020](#):
>
> 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:

 ![fcc-iss-1](https://global.discourse-cdn.com/freecodecamp/original/3X/6/3/63594b7809bf23d758d914a037a76fe800f57917.jpeg)  
And what’s going on FCC: ![fcc-iss-2](https://global.discourse-cdn.com/freecodecamp/original/3X/a/b/ab4ef66e729a7184a3d856e9900bc6401d5343c9.jpeg)  
And if i comment `NODE_ENV=test` back, i can pass everything but last challenge: ![fcc-iss-3](https://global.discourse-cdn.com/freecodecamp/original/3X/e/a/ea9a8722c7add793c6427787bd8972ae7364a778.jpeg)

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 6:32pm UTC](https://forum.freecodecamp.org/t/issue-tracker-projects-functional-tests-not-passing/435205/7 "2021-06-01T18:32:07Z")

</div>

Closed on June 1, 2021, 6:32pm UTC


