React & Modern Frontend (445 Qs)•Part 4: React Testing & Jest (95 - 100)
What is Jest?
Jest is a JavaScript unit testing framework created by Facebook based on Jasmine and provides automated mock creation and a jsdom environment. It's often used for testing components.
Practical Code Example
javascript
// Jest: Delightful JavaScript Testing Framework with built-in test runner, assertion library, and mock engine
describe('Math helpers', () => {
test('adds 1 + 2 to equal 3', () => {
expect(1 + 2).toBe(3);
});
});