Tests use test() or it() to define test cases:
function add(a, b) {
return a + b;
}
test('adds two numbers', () => {
expect(add(2, 3)).toBe(5);
});
The test describes what it checks. expect() makes an assertion about the result.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Writing a basic test
Tests use test() or it() to define test cases:
function add(a, b) {
return a + b;
}
test('adds two numbers', () => {
expect(add(2, 3)).toBe(5);
});
The test describes what it checks. expect() makes an assertion about the result.