Quality Assurance Project: Metric-Imperial Converter

Tell us what’s happening:

I am almost done with this Metric-Imperial Converter project but I have problem with the last two tests:

  • All 16 unit tests are complete and passing.
  • All 5 functional tests are complete and passing.

What am I doing wrong that does not allow me to pass the last two tests?
I was able to run the tests on the Replit console, by typing in npm run test.
It shows all 21 test pass. But then why am I not able to pass the freeCodeCamp test?

I also need help understanding what this means,

  • Copy the sample.env file to .env and set the variables appropriately

Do I have to create something for the Secret Environment Variables (padlock icon)?
I tried to create my own .env file, which I named my-own.env file. Then I just copied and paste the PORT=3000 into my .env file.

What does it mean when, “To run the tests uncomment NODE_ENV=test in your .env file” ?
What does this requirement from FCC want me to do and how do I do it on Replit?

I appreciate any help.

My Replit Link: https://replit.com/@ArtC/boilerplate-project-metricimpconverter-ls#tests/2_functional-tests.js

Your browser information:

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

Challenge: Metric-Imperial Converter

Link to the challenge:

Hello there,

This sort of confusion is usually resolved by this point in the curriculum. However, if you have skipped some of the previous lessons, the just is:

  • In most development environments you will see/use a .env file (this is its full name).
  • The .env file often contains secrets (e.g. database credentials), thus cannot be shared publicly
  • As such, it is common to include with your project a sample.env file that contains the boilerplate (outline) of what is needed in a .env file
  • This year, Replit disabled the use of .env files, for the SECRETS tab - functionally, the same thing.
  • You should add whatever is necessary to the SECRETS tab based on the instructions.

Debugging based on the devtools:

It looks like you might need to add NODE_ENV=true to the SECRET tab

Hope this helps

I took your advice to add NODE_ENV=true to the SECRET tab.

I went back to my Replit. I typed in Secrets System environment variables.
I put in key is NODE_ENV and value is true.

Then I click the insert button and got const mySecret = process.env['NODE_ENV']
I put that const mySecret in the server.js file.
I put it below the const cors = require('cors');

const express     = require('express');
const bodyParser  = require('body-parser');
const expect      = require('chai').expect;
const cors        = require('cors');
//=== Use advice from FCC help, Add NODE_ENV=true to the SECRET tab
const mySecret = process.env['NODE_ENV']
//===========

I ran my test on FCC and it still does not allow me to pass. I still cannot pass the last two tests.

What about the sample.env file? I see it has PORT & # NODE_ENV

PORT=3000
# NODE_ENV=test

Am I suppose to leave it alone or do I have to do something with it?
I read through the FCC project test. It requires me to work in the following replit files:

  • /controllers/convertHandler.js
  • /routes/api.js
  • tests/1_unit-tests.js
  • tests/2_functional-tests.js

Did I also have to work on the server.js file? Am I suppose to also add a dependency in the package.json file?

Ok, I was finally able to get my replit code to pass the FCC test by typing in Secrets Environment Variables

Key: NODE_ENV
Value: test

Then I insert the const mySecret code in the server.js file.

Thank you very much for your help! :slight_smile:

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