2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
|
title: Learn How JavaScript Assertions Work
|
|
|
|
|
---
|
|
|
|
|
## Learn How JavaScript Assertions Work
|
|
|
|
|
|
2019-07-02 07:00:18 +10:00
|
|
|
To begin, locate the file "tests/1_unit_tests.js".
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-02 07:00:18 +10:00
|
|
|
This file contains multiple suites of tests for the project, and this first challenge requires you to make the tests in ` /** 1 */` to pass.
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-02 07:00:18 +10:00
|
|
|
## Hint 1
|
|
|
|
|
|
|
|
|
|
The two lines in the test should be changed from `assert.fail()` to either `assert.isNull()` or `assert.isNotNull()`.
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
/** 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');
|
|
|
|
|
});
|
|
|
|
|
```
|