TDD Lifecycle Revisited
Continue writing tests, and begin fixing them with production code.
Our first unit test
Once we have our first integration test failing, it is time to write our first unit tests.
Unit tests are designed to test system components in isolation.
To make isolation of system components possible, we will create multiple components: TaskInput
to input new tasks and TaskList
to display a list of tasks.
Create a folder called components
in src
and create a file called TaskInput.test.js
. This file will hold tests for the TaskInput
component, which we have yet have to create.
Now, we will learn some more Jest functions. If you recall, we defined our integration tests with the test
function. This is also possible for unit tests. But we are going to learn one more approach, and then you can decide whichever approach you can prefer.
Another way of organizing tests is by using the describe
and it
functions. describe
is a function to group multiple tests together, and it
is the same as the test
...
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy