Software Engineer @MindfireSolutions
Unit Tests
Integration Tests
E2E
Tests
💰🤑💰
cheap
🐢
🏎️
Test
Fails
Test
Passes
Refactor
JavaScript Testing Framework
Developed by Facebook
Works with React/Angular/Vue/Node/TypeScript/Babel
Fast
Function Mock
Code Coverage & Snapshots
test
describe
expect
toBe
toEqual
test('test description', () => {
//business logic...
})
describe('section to group similar test', () => {
test('test 1', () => {
//business logic...
})
test('test 2', () => {
// another business logic...
})
})
expect(2).toBe(2); // will pass
expect(true).toBe(false); // will fail
expect(["one", "two", "three"])
.toEqual(["one", "two", "three"]); // will pass
expect({ name: "Sanjeev Yadav"})
.toEqual({ name: "Sanjeev Yadav"}); // will pass
test('sum of 2 + 2 is 4', () => {
const result = add(2, 2);
expect(result).toBe(4);
});
Jest.js
enzyme.js
article