Metric-Imperial Converter: error with no specification

Hello. I’m taking on the challenge Metric-Imperial Converter, and I’m almost done.
The Chai tests all pass, the console gives me the following message:

Running Tests ...

  Unit Tests
    ✓ Read a whole number
    ✓ Read a decimal number
    ✓ Read a fractional number
    ✓ Read a fractional number with decimal
    ✓ Error with double fraction unput
    ✓ Default to 1 if no number in input
    ✓ Read a correct unit input
    ✓ Refuses a non-corret unit input
    ✓ Return the correct return-unit
    ✓ Return the correctly spelled out unit
    ✓ Correctly converts from one unit to the others

  Functional Tests
    ✓ get {input: "10l"} (74ms)
    ✓ get {input: "32g"}
    ✓ get {input: "3/7.2/4kg"}
    ✓ get {input: "3/7.2/4kilomegagram"}
    ✓ get {input: "kg"}

  16 passing (127ms)

But the system test does not pass. The error that is returned to me is:

(*) All 16 unit tests are complete and passing.
(v) All 5 functional tests are complete and passing.

It therefore seems that the functional tests all pass, while there would be an error in the unit tests.

It seems to me that I built the tests exactly as required by the specifics of the problem.

What can be the mistake?

I enclose the invitation to replit, in case anyone wants to take a look at the code.

https://replit.com/join/prvnvhpd-thornduke

Hi, you’re almost there. Keep it up!

The confirmation script when submitting the project is based on this document.

Here is the confirmation code that you hope to complete.

// All 16 unit tests are complete and passing.

async getUserInput => {
  try {
    const getTests = await $.get(getUserInput('url') + '/_api/get-tests');
    assert.isArray(getTests);
    const unitTests = getTests.filter(test => {
      return !!test.context.match(/Unit Tests/gi);
    });
    assert.isAtLeast(unitTests.length, 16, 'At least 16 tests passed');
    unitTests.forEach(test => {
      assert.equal(test.state, 'passed', 'Tests in Passed State');
      assert.isAtLeast(
        test.assertions.length,
        1,
        'At least one assertion per test'
      );
    });
  } catch (err) {
    throw new Error(err.responseText || err.message);
  }
};

As you can see, test runner finds and counts the “test” context in your tests/1_unit-tests.js via chai-http. (This is amazing for me!)

Now you have the 11 test context in your tests/1_unit-tests.js.
So you may pass the test after adding another 5 test contexts :slight_smile:

Here is my submitted source code as an example.

I hope this would be any help.

It works. Many thanks.

1 Like

Hey @akiko-pusu (or anyone really :smile:) can you give me some guidance? I’m having a similar issue to @SergioSpina. All of my tests pass locally, but both unit tests and functional tests don’t pass when I submit them to FCC. I have my live version of my app here, and my GitHub repo here.

I noticed I sometime get this error when submitting on the FCC website, but I haven’t found it to be particularly meaningful!

I would really appreciate any help as I’ve been stuck on this issue well over an hour already :worried:

1 Like

Hi, @camchardukian

FCC’s chai-http sends the request to the endpoint “/_api/get-tests”.
Please see the server.js / line: 44.

So environment variable needs to defined as “NODE_ENV=test” .

    1. Use .env file.
    • copy sample.env as .env in the same directory.
    • Comment out this line # NODE_ENV=test to NODE_ENV=test
    • Press start button
    1. Or set the environment variable from the terminal and run npm start

Exp.

# on your terminal or replit's terminal
export NODE_ENV=test
npm run start

In case NODE_ENV=test is specified, before starting the Web service, unit tests and function tests are executed.
If no problem, web service starts to listen the request.

Then you may pass the FCC’s check :slight_smile:

1 Like

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