Style sensitivity in QA Functional Tests

Style sensitivity in QA Functional Tests
0

Tell us what’s happening:
Test is failing on FCC while passing in the testrunner output. The FCC system requires you to use ’ (single quotes) in your test case, while the test runner and language obviously do not. Worse still, using the built in formatter on Glitch changes single quotes to double quotes. So formatting your Glitch code will cause test failures on FCC.

Your code so far
Failing code excerpt (note the double quotes):

assert.equal(
  res.body.surname,
  "Colombo",
  'res.body.surname should be "Colombo"'
);

Passing code (change to single quotes. meaning is unchanged, purely a style difference):

assert.equal(
  res.body.surname,
  'Colombo',
  'res.body.surname should be "Colombo"'
);

Your browser information:

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

Challenge: undefined

Link to the challenge:
https://www.freecodecamp.org/learn/information-security-and-quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-on-an-api-response-using-chai-http-iii---put-method

Similar problem with destructuring. This code passes in the testrunner output, fails on FCC.

test('send {surname: "da Verrazzano"}', function(done) {
        /** place the chai-http request code here... **/
        chai
          .request(server)
          .put("/travellers")
          .send({ surname: "da Verrazzano" })
          .end((err, { status, type, body }) => {
            /** place your tests inside the callback **/
            assert.equal(status, 200, "response status should be 200");
            assert.equal(type, 'application/json');

            assert.equal(body.name, 'Giovanni');
            assert.equal(body.surname, 'da Verrazzano');
            done();
          });
      });

Adjusting it to remove destructuring (and type res. over and over) passes on FCC:

test('send {surname: "da Verrazzano"}', function(done) {
        /** place the chai-http request code here... **/
        chai
          .request(server)
          .put("/travellers")
          .send({ surname: "da Verrazzano" })
          .end((err, res) => {
            /** place your tests inside the callback **/
            assert.equal(res.status, 200, "response status should be 200");
            assert.equal(res.type, 'application/json');

            assert.equal(res.body.name, 'Giovanni');
            assert.equal(res.body.surname, 'da Verrazzano');
            done();
          });
      });

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

1 Like

Issue link