Quality Assurance and Testing with Chai - Learn How JavaScript Assertions Work

Tell us what’s happening:

boilerplate-mochachai - Replit
my code doesn’t work even though i’m doing everything right. Please help me slove this problem

###Your project link(s)

solution: boilerplate-mochachai - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

Challenge Information:

Quality Assurance and Testing with Chai - Learn How JavaScript Assertions Work

when you run the tests, what errors do you see in the browser console?

automated-testing-app@0.0.1 start
node server.js

Listening on port 3000
Running Tests…

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

Functional Tests
Integration tests with chai-http
15) Test GET /hello with no name
16) Test GET /hello with your name
17) Send {surname: “Colombo”}
18) Send {surname: “da Verrazzano”}

Functional Tests with Zombie.js
Headless browser
19) should have a working “site” property
“Famous Italian Explorers” form
20) Submit the surname “Colombo” in the HTML form
21) Submit the surname “Vespucci” in the HTML form

4 passing (68ms)
21 failing

  1. Unit Tests
    Equality
    #equal, #notEqual:
    AssertionError: Numbers are coerced into strings with ==
    at Context. (tests/1_unit-tests.js:40:14)
    at process.processImmediate (node:internal/timers:483:21)

  2. Unit Tests
    Equality
    #strictEqual, #notStrictEqual:
    AssertionError: assert.fail()
    at Context. (tests/1_unit-tests.js:47:14)
    at process.processImmediate (node:internal/timers:483:21)

  3. Unit Tests
    Equality
    #deepEqual, #notDeepEqual:
    AssertionError: The order of keys doesn’t matter
    at Context. (tests/1_unit-tests.js:54:14)
    at process.processImmediate (node:internal/timers:483:21)

  4. Unit Tests
    Comparisons
    #isAbove, #isAtMost:
    AssertionError: assert.fail()
    at Context. (tests/1_unit-tests.js:68:14)
    at process.processImmediate (node:internal/timers:483:21)

  5. Unit Tests
    Comparisons
    #isBelow, #isAtLeast:
    AssertionError: assert.fail()
    at Context. (tests/1_unit-tests.js:75:14)
    at process.processImmediate (node:internal/timers:483:21)

  6. Unit Tests
    Comparisons
    #approximately:
    AssertionError: assert.fail()
    at Context. (tests/1_unit-tests.js:82:14)
    at process.processImmediate (node:internal/timers:483:21)

  7. Unit Tests
    Arrays
    #isArray, #isNotArray:
    AssertionError: assert.fail()
    at Context. (tests/1_unit-tests.js:94:14)
    at process.processImmediate (node:internal/timers:483:21)

  8. Unit Tests
    Arrays
    Array #include, #notInclude:
    AssertionError: It’s summer in july…
    at Context. (tests/1_unit-tests.js:99:14)
    at process.processImmediate (node:internal/timers:483:21)

  9. Unit Tests
    Strings
    #isString, #isNotString:
    AssertionError: assert.fail()
    at Context. (tests/1_unit-tests.js:112:14)
    at process.processImmediate (node:internal/timers:483:21)

  10. Unit Tests
    Strings
    String #include, #notInclude:
    AssertionError: ‘Arrow’ contains ‘row’
    at Context. (tests/1_unit-tests.js:118:14)
    at process.processImmediate (node:internal/timers:483:21)

  11. Unit Tests
    Strings
    #match, #notMatch:
    AssertionError: assert.fail()
    at Context. (tests/1_unit-tests.js:124:14)
    at process.processImmediate (node:internal/timers:483:21)

  12. Unit Tests
    Objects
    #property, #notProperty:
    AssertionError: Cars don’t have wings
    at Context. (tests/1_unit-tests.js:150:14)
    at process.processImmediate (node:internal/timers:483:21)

  13. Unit Tests
    Objects
    #typeOf, #notTypeOf:
    AssertionError: assert.fail()
    at Context. (tests/1_unit-tests.js:156:14)
    at process.processImmediate (node:internal/timers:483:21)

  14. Unit Tests
    Objects
    #instanceOf, #notInstanceOf:
    AssertionError: assert.fail()
    at Context. (tests/1_unit-tests.js:164:14)
    at process.processImmediate (node:internal/timers:483:21)

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

  16. Functional Tests
    Integration tests with chai-http
    Test GET /hello with your name:
    Uncaught AssertionError: assert.fail()
    at /home/runner/workspace/tests/2_functional-tests.js:31:18
    at Request.callback (node_modules/superagent/lib/node/index.js:716:12)
    at IncomingMessage. (node_modules/superagent/lib/node/index.js:916:18)
    at IncomingMessage.emit (node:events:536:35)
    at endReadableNT (node:internal/streams/readable:1698:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

  17. Functional Tests
    Integration tests with chai-http
    Send {surname: “Colombo”}:
    Uncaught AssertionError: assert.fail()
    at /home/runner/workspace/tests/2_functional-tests.js:44:18
    at Request.callback (node_modules/superagent/lib/node/index.js:716:12)
    at /home/runner/workspace/node_modules/superagent/lib/node/index.js:916:18
    at IncomingMessage. (node_modules/superagent/lib/node/parsers/json.js:19:7)
    at IncomingMessage.emit (node:events:536:35)
    at endReadableNT (node:internal/streams/readable:1698:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

  18. Functional Tests
    Integration tests with chai-http
    Send {surname: “da Verrazzano”}:
    AssertionError: assert.fail()
    at Context. (tests/2_functional-tests.js:51:14)
    at process.processImmediate (node:internal/timers:483:21)

  19. Functional Tests with Zombie.js
    Headless browser
    should have a working “site” property:
    ReferenceError: browser is not defined
    at Context. (tests/2_functional-tests.js:67:24)
    at process.processImmediate (node:internal/timers:483:21)

  20. Functional Tests with Zombie.js
    “Famous Italian Explorers” form
    Submit the surname “Colombo” in the HTML form:
    AssertionError: assert.fail()
    at Context. (tests/2_functional-tests.js:74:14)
    at process.processImmediate (node:internal/timers:483:21)

  21. Functional Tests with Zombie.js
    “Famous Italian Explorers” form
    Submit the surname “Vespucci” in the HTML form:
    AssertionError: assert.fail()
    at Context. (tests/2_functional-tests.js:80:14)
    at process.processImmediate (node:internal/timers:483:21)

please check the browser console in the Dev Tools of the browser

Failed to load resource: the server responded with a status of 400 ()
Failed to load resource: the server responded with a status of 400 ()
Banner not shown: beforeinstallpromptevent.preventDefault() called. The page must call beforeinstallpromptevent.prompt() to show the banner.
framework-904731c5b6fb1461.js:1 Error while parsing the ‘sandbox’ attribute: ‘allow-downloads-without-user-activation’ is an invalid sandbox flag.
Unrecognized feature: ‘ambient-light-sensor’.
Unrecognized feature: ‘battery’.
Unrecognized feature: ‘execution-while-not-rendered’.
Unrecognized feature: ‘execution-while-out-of-viewport’.
Unrecognized feature: ‘layout-animations’.
Unrecognized feature: ‘layout-animations’.
Unrecognized feature: ‘legacy-image-formats’
Unrecognized feature: ‘navigation-override’
Unrecognized feature: ‘oversized-images’.
Unrecognized feature: ‘publickey-credentials’.
Unrecognized feature: ‘speaker-selection’.
Unrecognized feature: ‘unoptimized-images’.
Unrecognized feature: ‘unsized-media’.
Unrecognized feature: ‘pointer-lock’.
Allow attribute will take precedence over ‘allowfullscreen’.
Allow attribute will take precedence over ‘allowpaymentrequest’.
Error while parsing the ‘sandbox’ attribute: ‘allow-downloads-without-user-activation’ is an invalid sandbox flag.
Error while parsing the ‘sandbox’ attribute: ‘allow-downloads-without-user-activation’ is an invalid sandbox flag.
Error while parsing the ‘sandbox’ attribute: ‘allow-downloads-without-user-activation’ is an invalid sandbox flag
Failed to load resource: the server responded with a status of 400 ()
Failed to load resource: the server responded with a status of 400 ()Understand this error

It seems you have some things to work on
I am unsure where those errors come from

were this in the console in the freecodecamp page?

this is a replit console

Access to XMLHttpRequest at ‘boilerplate-mochachai - Replit’ from origin ‘null’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

dom-test-evaluator.js:2
GET boilerplate-mochachai - Replit net::ERR_FAILED 200 (OK)

dom-test-evaluator.js:2 Error
at Object.eval (eval at #a (dom-test-evaluator.js:2:254989), :7:13)
at u (dom-test-evaluator.js:2:163654)
at l (dom-test-evaluator.js:2:163956)

is that from the browser console when you are running the tests?
it looks like something that needs fixing

yes! How I can fix that ?

try searching the forum for people having CORS issues and how they solved them

1 Like

thnak you for your help

I couldn’t find anything similar to my error

have you tried searching exactly your error?
https://forum.freecodecamp.org/search?q=origin%20%27null%27%20has%20been%20blocked%20by%20CORS%20policy%3A%20No%20%27Access-Control-Allow-Origin%27%20header%20is%20present%20on%20the%20requested%20resource.%20order%3Alatest

yes, I tried! But maybe I’m missing sometging, because I’m new to this

try checking the topics from that search