Sudoku Solver all tests passing except final two

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?

Your code so far
My solution

Your browser information:

User Agent is: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0.

Challenge: Sudoku Solver

Link to the challenge:

Hello,

I had the same issue as you.

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.

Here is my thread:

1 Like

That’s so odd. Will try again in the next days. Thanks for the info

Similar thing at my place. All my tests are passing and all FCC tests passes except “All 12 unit tests are complete and passing…”

:thinking:

I will leave for a while…

I’m using a mix of assert. and expect() in my unit tests.
I suspect assertion-analyser.js only allows assert.. Time is up for today…

Replaced all the expect().to.throw() with assert.fail() in my unit tests.

Added a few console.log() in the assertion-analyser.js which now tells all my 12 unit tests have assertions (unlike before).

Still stuck on the second last test.

Please help!

Sorry, forgot something: Link to my code

hey mattiasinokuchi, I haven’t used expect anywhere, so I’m not sure if it’s related.

Got it working!

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… :upside_down_face:

2 Likes

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!