Stock price checker always fails tests

in the challenge >Stock Price Checker< the tests seem to fail always, even if the actual tests in app succeeds, is there any one who managed to get them to work, any help would be appreciate

project link(s)


Your browser information:

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

Challenge: Stock Price Checker

Link to the challenge:

Is the NODE_ENV set to true in .env file? That is required for functional tests results to be accessed from the outside.

than you for your response, yes the NODE_ENV is set to ‘test’ to satisfy
if(process.env.NODE_ENV===‘test’) but my procees.env variables seem to be all Undefined so i forced the if statement if(process.env.NODE_ENV===‘test’ || true) this way i execute all the tests, results:
Listening on port undefined
Running Tests…

Functional Tests
GET /api/stock-prices => stockData object
====== { stockData: { stock: ‘goog’, price: 2225.55, likes: 0 } }
✓ 1 stock (1590ms)
------- { stockData: { stock: ‘goog’, price: 2225.55, likes: 1 } }
✓ 1 stock with like (291ms)
______ {}
✓ 1 stock with like again (ensure likes arent double counted) (119ms)
++++++++ {
stockData: [
{ stock: ‘msft’, price: 249.07, likes: 0, rel_likes: 0 },
{ stock: ‘spot’, price: 273.3, likes: 0, rel_likes: 0 }
✓ 2 stocks (248ms)
******** {
stockData: [
{ stock: ‘msft’, price: 249.07, likes: 1, rel_likes: 0 },
{ stock: ‘spot’, price: 273.3, likes: 1, rel_likes: 0 }
✓ 2 stocks with like (372ms)

5 passing (3s)
but when i submit the live project link every thing passes except for the last test_phase

Just to make sure, it needs to be set in the newly created file named .env (that’s literally the name).

yes sample.env
DB = # here goes the mongo conection string from atlas
thank you again.
ps there is always require(‘dotenv’).config(); at the top

Not sample.env, it should be named literally .env that’s (dot)-e-n-v.

1 Like

yes it works
well i m using replit it does not have any .env so i exported the entire thing to glitch.
thank you so mutch :slight_smile: :slight_smile: :slight_smile: :slight_smile:

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