ch09-NotFound
Last updated
Last updated
In the Angular version of the app, the component mainly consists of an icon and span, wrapped by divs for styling.
Create a branch feat/NotFound
. Create 2 files under src/components/
folder; NotFound.cy.tsx
, NotFound.tsx
. As usual, start minimal with a component rendering; copy the below to the files and execute the test after opening the runner with yarn cy:open-ct
.
To make the test pass, we create a minimal component (Green 1).
This one is a simple component, there aren't any more worthwhile tests to add. All we have left are the styles. We can copy those from the Angular version of the app (Refactor 1).
This one was a simple component where we solidified some of the past learnings.
In a component test, we can immediately setup the styles. In our examples so far this has been a simple import.
It is profitable to take advantage of react-icons
and / or styles-icons
.
Cypress component tests can aid our visual design in RedGreenRefactor cycles.
Write a test for the skeleton of the component we would like to have (Red 1). Until now we have been using Cypress' . Since we are testing a component and everything is under one tag, using within is optional. We can also import the styles into component at the beginning, since we will do it later as with every component.
We would like that svg
to be an actual icon. Let's import a triangle icon with an exclamation inside from . Of significance here is the test tool aiding our design in a RedGreenRefactor cycle (Refactor 1).