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

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

#1

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


#2

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.


#3

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?


#4

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…


#5

Thanks for heads up!


#6

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!


#7

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.


#8

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


#9

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