Unable to complete QA Projects American British Translator Project

Tell us what’s happening:
When I enter my project solution into page it fails with:

// running tests
All 24 unit tests are complete and passing. See /tests/1_unit-tests.js for the expected behavior you should write tests for.
All 6 functional tests are complete and passing. See /tests/2_functional-tests.js for the functionality you should write tests for.
// tests completed

I am unable to determine why it is failing as my code appears to be correct. I have looked at the tests being run on Github

I have verified that I am getting results from the /_api/get-tests endpoint. The result is an array, it contains 24 unit tests and 6 functional tests. The state of all the tests is ‘passed’ and each test does contain at least 1 assertion.

Your code so far

Your browser information:

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

Challenge: American British Translator

Link to the challenge:

Hey there,

I notice I cannot get the tests to run with:

node ./server.js NODE_ENV=test

Have you changed anything?

Some have found success with increasing the timeout:

if (process.env.NODE_ENV==='test') {
    console.log('Running Tests...');
    setTimeout(function () {
      try {
      } catch (error) {
        console.log('Tests are not valid:');
    }, 1500); // Change to something like 5000

Changing the timeout value did not make any difference in my results when submitting.

I haven’t changed anything in the code other than the timeout value, but I did notice that while

node ./server.js NODE_ENV=test

works for me locally, it didn’t work on repl.it

Either of these commands in the shell console did work though:

env NODE_ENV=test node ./server.js
env NODE_ENV=test npm run start

I’ve run in to this a couple of times with repl.it myself - without being able to identify reproduction steps. It seems intermittent that repl.it will persist the node process after the tests finish, or terminate it.

I, personally, use nodemon to work around the issue.

The issue really appears to be on the freeCodeCamp side to me. I added the following console.log() statement to this code in fcctesting.js:

  function(req, res, next){
    if(!runner.report) return next();
    console.log(testFilter(runner.report, req.query.type, req.query.n))
    res.json(testFilter(runner.report, req.query.type, req.query.n));

In the console log I see it logging the results like this:

[ { title:
    'Mangoes are my favorite fruit. -> Mangoes are my favourite fruit.',
  context: ' -> Unit Tests',
  state: 'passed',
  assertions: [ [Object] ] },
  { title:
      'I ate yogurt for breakfast. -> I ate yoghurt for breakfast.',
    context: ' -> Unit Tests',
    state: 'passed',
    assertions: [ [Object] ] },
    --- snipped for brevity ---
  { title:
      'Translation with empty text: POST request to /api/translate',
    context: ' -> Functional Tests',
    state: 'passed',
    assertions: [ [Object], [Object], [Object] ] },
  { title:
      'Translation with text that needs no translation: POST request to /api/translate',
    context: ' -> Functional Tests',
    state: 'passed',
    assertions: [ [Object], [Object], [Object] ] } ]

However, in the browser console, I am seeing the following errors when I submit the project:

 Error: At least 24 tests passed: expected 0 to be at least 24
    at eval (eval at <anonymous> (frame-runner.js:84), <anonymous>:18:11)
    _callee$ @ frame-runner.js:100
 Error: At least 6 tests passed: expected 0 to be at least 6
    at eval (eval at <anonymous> (frame-runner.js:84), <anonymous>:18:11)
    _callee$ @ frame-runner.js:100

EDIT: I also tried using glitch to run the project and I get the same results when I submit as I do when running it on repl.it

Okay, I see what’s going on there - this is a bug that occurred when we removed the test structure from the boilerplate, and it has to do with the way the tests are nested (or not nested) when you write them.

There’s a PR that has been merged into master but hasn’t shipped to production yet:

I can’t make any promises on when we will next run a deploy, but if you’d like to put the project on pause until then the issue should resolve when this lands.

Otherwise, I believe it can be circumvented by wrapping your tests in a suite within your suite.

1 Like

I added the arrow’s to the definitions of the suite and it passed. I didn’t see that PR when I was searching on Github, thanks for pointing me to it.

1 Like

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