Tell us what’s happening:
I believe I’ve written all the required tests. The challenge page shows that all of them are passing. However, I’m not passing the final two requirements:
All 12 unit tests are complete and passing. See /tests/1_unit-tests.js for the expected behavior you should write tests for.
and
All 14 functional tests are complete and passing. See /tests/2_functional-tests.js for the functionality you should write tests for.
I already have 12 unit and 14 functional tests passing, so I’m not sure what more I can do?
I kept on trying the FCC tester, and it passed all of a sudden. I believe FCC tester times out before completing it, or there is a strange bug in play.
I did some digging and found this document on the freeCodeCamp repo which gives some hints to what’s going on. Maybe it can help others. The code bellow the “All 12 unit tests are complete and passing.” is:
async (getUserInput) => {
try {
const getTests = await $.get(getUserInput('url') + '/_api/get-tests');
assert.isArray(getTests);
const units = getTests.filter((el) => el.context.includes('UnitTests'));
assert.isAtLeast(units.length, 12, 'At least 12 tests passed');
units.forEach((test) => {
assert.equal(test.state, 'passed', 'Test in Passed State');
assert.isAtLeast(
test.assertions.length,
1,
'At least one assertion per test'
);
});
} catch (err) {
throw new Error(err.responseText || err.message);
}
};
It isn’t clear to me whether this is the actual code being run by fcc’s server. But I’m assuming it’s something similar.
The /_api/get-tests endpoint is described in the routes/fcctesting.js in the boilerplate code and it seems like all it’s doing is using assertion-analyser.js and test-runner.js to go over your test files and count the individual tests.
In my case, however, the problem was simply that I had previously commented out NODE_ENV=test from my .env file (which is a condition on the /_api/get_tests route) because my repl.it server was shutting down after running the tests for some reason. Uncommented it today and got all tests passing…
Congratulations! Could you share the code? I had same problem with repl.it server shutting down now and then. Since previous project I know tests need to be uncommented in order for the FCC testing to pass. Thanks anyway!
Thanks man! The NODE_ENV=test was the key! I’ve been struggling with this for days, checking all edge cases to tests… thought it was something on my code!
Do you now if replacing expect with assert solved the problem. Unfortunately I struggle with same problem with last two tests not working.
NODE_ENV=test is uncommented repo