February 2019
Intermediate to advanced
204 pages
4h 52m
English
Let's explore some of the most basic ES6 testing scenarios, shown in the following table.. You can find the working example in the GitHub repository, inside of the CH02 folder:
|
Designation |
JEST test methods |
|
Matchers |
it("Matchers", () => {expect(24 + 20).toBe(44);expect({ one: 1, two: 3 }).toEqual({ one: 1, two: 3 });for (let i = 1; i < 10; i++) {for (let j = 1; j < 10; j++) {expect(i + j).not.toBe(0);}}}); |
|
Truetiness |
it("Truetiness", () => {const isActive = null;expect(isActive).toBeNull();expect(isActive).toBeDefined();expect(isActive).not.toBeUndefined();expect(isActive).not.toBeTruthy();expect(isActive).toBeFalsy(); }); |
|
Zeros |
it("zeros", () => {const z = 0;expect(z).not.toBeNull();expect(z).toBeDefined(); ... |
Read now
Unlock full access