Test-Driven Development
Learn about test-driven development and how to write a test using the Jest framework.
We'll cover the following...
Perhaps a brief explanation of that concept is in order. Test-driven development (TDD) comes from the Extreme Programming movement. Its core idea is to create a test that verifies the code’s behavior before actually writing that code. Let’s write a function that adds two numbers.
Writing test
Before writing code, we’ll create the following test using the Jest framework:
Press + to interact
describe('sum tests', () => {test('should return two when given one and one', () => {const result = sum(1, 1);expect(result).toBe(2);});});
Obviously, this test fails because we lack a ...
Access this course and 1400+ top-rated courses and projects.