Skip to content

yozibak/tdd-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React TDD demonstration 🐐

This small repo is to demonstrate how testing/TDD works in React project.

You can read detailed instructions here: https://yozibak.com/tdd-test-driven-development-basics-tutorial-with-typescriptreact

Exercise 1 - Basics of Jest

  1. Write sumArr() function that returns the sum of incoming array of int.
  2. Test sumArr() with jest.
  3. Change implementation of sumArr(), assuring result running test.

Answer

-> git checkout ex1/answer

Exercise 2 - Basics of React Testing Library

  1. Write test to ensure page title is shown
  2. Write test to ensure current number of reviews is shown
  3. Write test to ensure form submission is properly reflecting form values

Answer

-> git checkout ex2/answer

Exercise 3 - Basics of TDD

Implement validation on form submit, but test first.

Form Validation Requirements

  • title < 50 characters
  • score 0 ~ 100 pts
  • comment < 400 characters

Answer

-> git checkout ex3/answer

Exercise 4 - Separation of Concern

Show average review score on top of questionnaire form.

Answer

-> git checkout ex4/answer