Member-only story
How to TDD with BDD-Gherkin 4.2: Fetch with Redux
Previously we have followed a different path, and we had started to implement from Redux. Now, we will add services.
The current article is a hands-on experience to learn TDD/BDD. It is designed to learn by copy, TDD and all its small steps. The article continues from the previous article:
And you can clone the result here (in the branch part1):
Install all dependencies with yarn
and verify that all tests pass with yarn test Shop.spec.js
.
🟢 Keep the tests running.
We only implemented the first test, and the implementation was partial. Also, if you examine the code, you will find that there is no remote fetch, and it is emulated by the fetchAllProducts
thunk that does nothing.
// src/app/productListSlice.js
import { createSlice } from "@reduxjs/toolkit";
export function selectProductList(state) {
return…