Why am I not passing this?

I need help with this test! I can’t pass this test, and it will not pass. So I need help to solve it.

Your code so far
This is the link it said to go to.:


Your browser information:

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

Challenge: Learn How JavaScript Assertions Work

Link to the challenge:

You have a lot of mistakes pls follow these
In the test brackets you should have test('#isDefined, #isUndefined',
And you have written the whole code wrong but I can’t explain I’m going to give the solution test('#isDefined, #isUndefined', function(){ assert.fail( null, 'null is not undefined'); assert.fail( undefined, 'undefined IS undefined'); assert.fail( 'hello', 'a string is not undefined' ); });
But no worries you can try next time

1 Like


I tried that, but I did not pass. I did all you said but did not work.

Can you explain what I should do briefly?

It’s not immediately clear when you do this the first time, but you are just completing the tests with the correct assertion methods. For example, in the first set of tests

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

you are using the isNull() and isNotNull() assertion methods to make the tests pass. The assertion method fail() will always fail. So to make the first test pass, since the first argument is null, you want to use the isNull() method like

assert.isNull(null, 'this is an optional error description - e.g. null is null');

and the test should pass, since null is null. Likewise, you would use isNotNull() on the second one since 1 is not null, and so on and so forth, replacing fail() with the correct method.

You can read about all the chai assertion methods (and lots more) in the documentation.

Good luck.

1 Like

Thank you SO much!

But one question: Which one do I replace with assert.isNull(null, 'this is an optional error description - e.g. null is null'); ?

Is this how my code suppose to look? (I will change the null.)

@jeremy.a.gray I changed it, but I still dont pass. :frowning_face: :frowning_face:

Don’t delete the code inside 1_unit-tests.js just change the assert methods from fail to the one the test is asking for.

It tells you what methods to use:

/** 1 - Use assert.isNull() or assert.isNotNull() to make the tests pass. **/

And the assert message itself for each assert is the hint as to what method each test should use.

'this is an optional error description - e.g. null is null'

Also, make sure the project is running and you are submitting the URL from the preview output address bar.

1 Like

Okay! Thank you. I figured it out by watching a video. I won’t post the video link, because I don’t think we are allowed, so thanks anyways! :grinning: :grinning: