-
Notifications
You must be signed in to change notification settings - Fork 0
/
exceptions.test.js
43 lines (37 loc) · 1.45 KB
/
exceptions.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* ************************ CHAPTER 7 ************************************************
* Exceptions
* ************************************************************************************
*
*
* @see https://jestjs.io/docs/en/api#testname-fn-timeout
* @author Abhijeet Bhagat
*
* NOTE :- if you need to run tests only in this test suite then use following command
* ****************************** COMMAND ********************************************
* ___________________________________________________________________________________|
* npm test -t exceptions.test.js |
* ___________________________________________________________________________________|
*/
const fthrow=require("./lib/funcsthrowexceptions");
/**
* You can check if a function throws an exception using toThrow matcher
*
*/
test('compiling android goes as expected', () => {
expect(fthrow).toThrow();
expect(fthrow).toThrow(Error);
// You can also use the exact error message or a regexp
expect(fthrow).toThrow('Demo Error');
expect(fthrow).toThrow(/Demo/);
});
/**
******************************** Quiz ***************************************************
* 1. when to use toThrow?
*
*/
/**
* next go to
* @see https://github.com/bhagatabhijeet/jestSamples/blob/master/async.test.js
* @see async.test.js
*/