Quality assurance challenge 1: Learn how js assertions work

Hi! I’m working on the first challenge of quality assurance. I’m getting errors in all fcc tests although everything is fine in my code, except this console output:

Listening on port 3000
Running Tests...


  Unit Tests
    Basic Assertions
      1) #isNull, #isNotNull
      2) #isDefined, #isUndefined
      3) #isOk, #isNotOk
      4) #isTrue, #isNotTrue
    Equality
      5) #equal, #notEqual
      6) #strictEqual, #notStrictEqual
      7) #deepEqual, #notDeepEqual
    Comparisons
      8) #isAbove, #isAtMost
      9) #isBelow, #isAtLeast
      10) #approximately
    Arrays
      11) #isArray, #isNotArray
      12) Array #include, #notInclude
    Strings
      13) #isString, #isNotString
      14) String #include, #notInclude
      15) #match, #notMatch
    Objects
      16) #property, #notProperty
      17) #typeOf, #notTypeOf
      18) #instanceOf, #notInstanceOf

  Functional Tests
    Integration tests with chai-http
      19) Test GET /hello with no name
      20) Test GET /hello with your name
      21) Send {surname: "Colombo"}
      22) Send {surname: "da Verrazzano"}

  Functional Tests with Zombie.js
    Headless browser
      23) should have a working "site" property
    "Famous Italian Explorers" form
      24) Submit the surname "Colombo" in the HTML form
      25) Submit the surname "Vespucci" in the HTML form


  0 passing (156ms)
  25 failing

  1) Unit Tests
       Basic Assertions
         #isNull, #isNotNull:

      This is an optional error description - e.g. null is null
      + expected - actual


      at Context.<anonymous> (tests/1_unit-tests.js:8:14)
      at processImmediate (node:internal/timers:466:21)

  2) Unit Tests
       Basic Assertions
         #isDefined, #isUndefined:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/1_unit-tests.js:13:14)
      at processImmediate (node:internal/timers:466:21)

  3) Unit Tests
       Basic Assertions
         #isOk, #isNotOk:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/1_unit-tests.js:19:14)
      at processImmediate (node:internal/timers:466:21)

  4) Unit Tests
       Basic Assertions
         #isTrue, #isNotTrue:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/1_unit-tests.js:25:14)
      at processImmediate (node:internal/timers:466:21)

  5) Unit Tests
       Equality
         #equal, #notEqual:
     AssertionError: Numbers are coerced into strings with ==
      at Context.<anonymous> (tests/1_unit-tests.js:36:14)
      at processImmediate (node:internal/timers:466:21)

  6) Unit Tests
       Equality
         #strictEqual, #notStrictEqual:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/1_unit-tests.js:43:14)
      at processImmediate (node:internal/timers:466:21)

  7) Unit Tests
       Equality
         #deepEqual, #notDeepEqual:
     AssertionError: The order of keys doesn't matter
      at Context.<anonymous> (tests/1_unit-tests.js:50:14)
      at processImmediate (node:internal/timers:466:21)

  8) Unit Tests
       Comparisons
         #isAbove, #isAtMost:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/1_unit-tests.js:64:14)
      at processImmediate (node:internal/timers:466:21)

  9) Unit Tests
       Comparisons
         #isBelow, #isAtLeast:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/1_unit-tests.js:71:14)
      at processImmediate (node:internal/timers:466:21)

  10) Unit Tests
       Comparisons
         #approximately:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/1_unit-tests.js:78:14)
      at processImmediate (node:internal/timers:466:21)

  11) Unit Tests
       Arrays
         #isArray, #isNotArray:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/1_unit-tests.js:90:14)
      at processImmediate (node:internal/timers:466:21)

  12) Unit Tests
       Arrays
         Array #include, #notInclude:
     AssertionError: It's summer in july...
      at Context.<anonymous> (tests/1_unit-tests.js:95:14)
      at processImmediate (node:internal/timers:466:21)

  13) Unit Tests
       Strings
         #isString, #isNotString:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/1_unit-tests.js:108:14)
      at processImmediate (node:internal/timers:466:21)

  14) Unit Tests
       Strings
         String #include, #notInclude:
     AssertionError: 'Arrow' contains 'row'
      at Context.<anonymous> (tests/1_unit-tests.js:114:14)
      at processImmediate (node:internal/timers:466:21)

  15) Unit Tests
       Strings
         #match, #notMatch:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/1_unit-tests.js:120:14)
      at processImmediate (node:internal/timers:466:21)

  16) Unit Tests
       Objects
         #property, #notProperty:
     AssertionError: Cars don't have wings
      at Context.<anonymous> (tests/1_unit-tests.js:146:14)
      at processImmediate (node:internal/timers:466:21)

  17) Unit Tests
       Objects
         #typeOf, #notTypeOf:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/1_unit-tests.js:152:14)
      at processImmediate (node:internal/timers:466:21)

  18) Unit Tests
       Objects
         #instanceOf, #notInstanceOf:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/1_unit-tests.js:160:14)
      at processImmediate (node:internal/timers:466:21)

  19) Functional Tests
       Integration tests with chai-http
         Test GET /hello with no name:
     Uncaught AssertionError: assert.fail()
      at /home/runner/boilerplate-mochachai/tests/2_functional-tests.js:18:18
      at Test.Request.callback (node_modules/superagent/lib/node/index.js:716:12)
      at IncomingMessage.<anonymous> (node_modules/superagent/lib/node/index.js:916:18)
      at IncomingMessage.emit (node:events:539:35)
      at endReadableNT (node:internal/streams/readable:1345:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21)

  20) Functional Tests
       Integration tests with chai-http
         Test GET /hello with your name:
     Uncaught AssertionError: assert.fail()
      at /home/runner/boilerplate-mochachai/tests/2_functional-tests.js:29:18
      at Test.Request.callback (node_modules/superagent/lib/node/index.js:716:12)
      at IncomingMessage.<anonymous> (node_modules/superagent/lib/node/index.js:916:18)
      at IncomingMessage.emit (node:events:539:35)
      at endReadableNT (node:internal/streams/readable:1345:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21)

  21) Functional Tests
       Integration tests with chai-http
         Send {surname: "Colombo"}:
     Uncaught AssertionError: assert.fail()
      at /home/runner/boilerplate-mochachai/tests/2_functional-tests.js:41:18
      at Test.Request.callback (node_modules/superagent/lib/node/index.js:716:12)
      at /home/runner/boilerplate-mochachai/node_modules/superagent/lib/node/index.js:916:18
      at IncomingMessage.<anonymous> (node_modules/superagent/lib/node/parsers/json.js:19:7)
      at IncomingMessage.emit (node:events:539:35)
      at endReadableNT (node:internal/streams/readable:1345:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21)

  22) Functional Tests
       Integration tests with chai-http
         Send {surname: "da Verrazzano"}:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/2_functional-tests.js:48:14)
      at processImmediate (node:internal/timers:466:21)

  23) Functional Tests with Zombie.js
       Headless browser
         should have a working "site" property:
     ReferenceError: browser is not defined
      at Context.<anonymous> (tests/2_functional-tests.js:64:24)
      at processImmediate (node:internal/timers:466:21)

  24) Functional Tests with Zombie.js
       "Famous Italian Explorers" form
         Submit the surname "Colombo" in the HTML form:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/2_functional-tests.js:71:14)
      at processImmediate (node:internal/timers:466:21)

  25) Functional Tests with Zombie.js
       "Famous Italian Explorers" form
         Submit the surname "Vespucci" in the HTML form:
     AssertionError: assert.fail()
      at Context.<anonymous> (tests/2_functional-tests.js:77:14)
      at processImmediate (node:internal/timers:466:21)

This is the link to my repl: https://replit.com/@redouane1/boilerplate-mochachai

I would be happy if someone help to figure out the problem.

This is from your Replit, the #1 test:

suite('Unit Tests', function () {
  suite('Basic Assertions', function () {
    // #1
    test('#isNull, #isNotNull', function () {
      assert.isNotNull(null, 'This is an optional error description - e.g. null is null');
      assert.isNull(1, '1 is not null');
    });

The value of the null is null.
And, the value of 1 is not null.

But, you are asserting otherwise in your test.

1 Like

In my mind, it was as you said. But, I made a mistake when typing. Thanks!

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