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

Has anyone started these challenges yet?

I am failing the first challenge. I am using tests/1_unit-tests.js

Not sure, what’s going on here. It’s my first time using Chai.

    assert.isNull('#isNull, #isNotNull', function(){
      assert.fail(null, 'this is an optional error description - e.g. null is null');
      assert.fail( 1, '1 is not null');

Here are the error logs.

// running test
expected undefined to equal ‘passed’
Cannot read property ‘0’ of undefined
Cannot read property ‘1’ of undefined
// tests completed


With all these kind of Chai challenges you are supposed to change the default assert.fail(...) into the test that they mention in the challenge. In this case it is assert.isNull(...) or assert.isNotNull(...). You have to figure out which one is the right test for each expected result.

1 Like

Thanks for clearing that up for me :slight_smile:

Also it’s really annoying to see those red dots with errors saying and suite and test aren’t defined. Is there a way to get rid of them in Glitch?

1 Like

I was wondering this too… I just ignored them :smiley: By the way when you get to test 10 there is a spelling error… check that it says assert.approximately for both tests…because it doesnt…somehow the bugfix from march isnt on the master yet…


Thanks for heads up!

I’m also confused about how to complete this challenge.

I modified 1_unit_tests.js as follows:

/** 1 - Use assert.isNull() or assert.isNotNull() to make the tests pass. **/
    test('#isNull, #isNotNull', function(){
      assert.isNull(null, 'this is an optional error description - e.g. null is null');
      assert.isNotNull( 1, '1 is not null');

Then I place my cursor at the beginning of this test, copy the glitch URL, and paste it into freeCodeCamp, but I receive the same error log as noted in the original post.

What am I doing incorrectly? Thanks!

1 Like

You don’t want to paste in the public url. Instead hit the share button on top left window and select the 2nd drop down to copy that url and use it.


test(’#isNull, #isNotNull’, function(){
assert.isNull(null, ‘this is an optional error description - e.g. null is null’);
assert.isNotNull( 1, ‘1 is not null’);

works for me

Hit the nail on the head. It’s a bit irritating that the directions for these challenges aren’t more well written.


Pulamusic: “It’s a bit irritatiing that the directions for these challenges aren’t more well written”
You hit the other nail on the head.
The deeper into these you go, the less and less useful information is given.

In a module called “Learn How JavaScript Assertions Work” no explination of what an assertion is, how they work, or how you would use one in a project is given.

The quality of the first lessons in FreeCodeCamp is incredible, but it falters and eventually just stops.


Very True. Chai is not explained. Assertions are not explained well enough

No idea why I’m doing what these challenges are telling me to do. Moto42’s comment is spot on.

I guess these chai challenges are a review of how comparison operators will evaluate, so is null == undefined? Is “2” == 2? Is “2”*2 === 4? etc

You’re right.
The url should be like this: https://zzzz-yyyy-xxxx.glitch.me
And the file should be called: tests/1_unit-tests.js , note each char that it contains.