User Stories NOT checking my code correctly - SUDOKU SOLVER

Tell us what’s happening:
Hello… i made a thread asking how to START tackling the Sudoku solver here “https://forum.freecodecamp.org/t/dont-know-where-to-start-in-sudoku-solver/446056x” and now I need help how to FINISH this project.

I passed all the tests EXCEPT these two tests:

If the object submitted to /api/solve is missing puzzle, the returned value will be { error: 'Required field missing' }

and

If the object submitted to /api/check is missing puzzle, coordinate or value, the returned value will be { error: Required field(s) missing }

…which is weird because when I pass a missing puzzle the API always return as expected an object {error: Required field(s) missing}. The FreeCodeCamp tester algorithm is not checking those two tests correctly. Even my Chai assertion tests passed the MISSING puzzle correctly. What seems to be the problem here? Is my code wrong? My code for API folder is here : https://repl.it/@synerjay/boilerplate-project-sudoku-solver#routes/api.js
Your project link(s)

solution: https://boilerplate-project-sudoku-solver.synerjay.repl.co

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36.

Challenge: Sudoku Solver

Link to the challenge:

Bump… can someone give me an insight? It’s still an ongoing issue:

If the object submitted to /api/solve is missing puzzle , the returned value will be { error: 'Required field missing' }

My chai assertion tests for this user story PASSED but NOT in the FCC website.

 test('Solve a puzzle with missing puzzle string', function(done) {
        chai.request(server)
        .post('/api/solve')
        .send({ puzzle: '' })
        .end(function(err, res){
          assert.equal(res.status, 200);
          assert.equal(res.body.error, "Required field missing")
          done();
        })
      });
// PASSED

An object with a missing puzzle is passed and the expected error is sent and it is passed.

Another user story that failed in the FCC website but not the Chai assertion test is this:

If the object submitted to /api/check is missing puzzle , coordinate or value , the returned value will be { error: Required field(s) missing }

Again, my chai assertion test for this PASSED but not in the FCC website:

test('Check a puzzle placement with missing required fields', function(done) {
        chai.request(server)
        .post('/api/check')
        .send({
          puzzle: '',
          coordinate: 'C3',
          value: '6'
        })
        .end(function(err, res){
          assert.equal(res.status, 200);
          assert.equal(res.body.error, "Required field(s) missing")
          done();
        })
      });
//PASSED

All the Chai assertion tests PASSED but FCC site says I failed on these two user stories… Can anyone tell me why?

Consider some edge cases:

  • what response will be when request to api/check is submitted with just one of the fields? In example with just puzzle.
  • what response will be when request to api/solve is submitted without puzzle field
1 Like

Hey there,

Here are the freeCodeCamp tests: freeCodeCamp/sudoku-solver.md at main · freeCodeCamp/freeCodeCamp (github.com)

If I have time later, I might go over your project. Otherwise, I recommend you use the tests done by freeCodeCamp to help debug.

Hope this helps

I changed condition statement to undefined and it did the trick. I misunderstood “missing” as “empty”. Working on the American-British translator gave me that “eureka” moment :crazy_face: