# mocha chai

***

**1. Simple Assertion**

```js
const assert = require('chai').assert;

assert.equal(4, 4);
```

**2. Multiple Assertions**

```js
assert.equal(4, 4);
assert.notEqual(4, 5);
```

**3. Truthiness Assertions**

```js
assert.isTrue(true);
assert.isFalse(false);
```

**4. Object Assertions**

```js
assert.deepEqual({ a: 1, b: 2 }, { a: 1, b: 2 });
assert.notDeepEqual({ a: 1, b: 2 }, { a: 1, b: 3 });
```

**5. Array Assertions**

```js
assert.sameMembers([1, 2, 3], [1, 2, 3]);
assert.notSameMembers([1, 2, 3], [1, 2, 4]);
```

**6. Function Assertions**

```js
assert.isFunction(() => {});
assert.notFunction(1);
```

**7. Exception Assertions**

```js
assert.throws(() => { throw new Error('Error'); });
assert.doesNotThrow(() => {});
```

**8. Property Assertions**

```js
assert.property({ a: 1, b: 2 }, 'a');
assert.notProperty({ a: 1, b: 2 }, 'c');
```

**9. Inclusion Assertions**

```js
assert.include([1, 2, 3], 2);
assert.notInclude([1, 2, 3], 4);
```

**10. Instanceof Assertions**

```js
assert.instanceOf(new Error(), Error);
assert.notInstanceOf(1, Error);
```

**11. RegExp Assertions**

```js
assert.match('abc', /^a/);
assert.notMatch('abc', /b$/);
```

**12. Close To Assertions**

```js
assert.closeTo(1.5, 1.6, 0.1);
assert.notCloseTo(1.5, 1.7, 0.1);
```

**13. Length Assertions**

```js
assert.lengthOf([1, 2, 3], 3);
assert.notLengthOf([1, 2, 3], 4);
```

**14. String Assertions**

```js
assert.startsWith('abc', 'a');
assert.endsWith('abc', 'c');
```

**15. Boolean Assertions**

```js
assert.isBoolean(true);
assert.isBoolean(false);
```

**16. Null Assertions**

```js
assert.isNull(null);
assert.isNotNull(1);
```

**17. Undefined Assertions**

```js
assert.isUndefined(undefined);
assert.isDefined(1);
```

**18. NaN Assertions**

```js
assert.isNaN(NaN);
assert.isNotNaN(1);
```

**19. Finite Assertions**

```js
assert.isFinite(1);
assert.isFinite(0);
```

**20. Positive Assertions**

```js
assert.isAbove(1, 0);
assert.isAtLeast(1, 1);
```

**21. Negative Assertions**

```js
assert.isBelow(0, 1);
assert.isAtMost(1, 1);
```

**22. Within Range Assertions**

```js
assert.isInRange(1, 0, 2);
assert.isNotInRange(1, 2, 4);
```

**23. Promise Assertions**

```js
assert.isFulfilled(Promise.resolve());
assert.isRejected(Promise.reject());
```

**24. Event Assertions**

```js
assert.emits(emitter, 'event');
assert.notEmits(emitter, 'event');
```

**25. HTTP Assertions**

```js
const assert = require('chai').assert;
const chaiHttp = require('chai-http');
const app = require('../app');

chai.use(chaiHttp);

it('should return a 200 status code', async () => {
  const res = await chai.request(app).get('/');
  assert.equal(res.status, 200);
});
```
