Git Product home page Git Product logo

react-testing-contact-form's Introduction

Contact Form - Testing

Advanced React Sprint

Testing Web Applications

Objectives

  • explain what automated testing is and its importance
  • use react-testing-library for testing react components
  • use react-testing-library to test user interactions with fireEvent

Introduction

In this challenge, you will be writing tests for a contact form that has been built with React.

As a developer, you will be writing tests for every component. As we've learned, tests are a very important part of programming. The tests you will write will help you feel confident in the code you push to production!

Project Set Up

  • Create a forked copy of this project.
  • Add your team lead as collaborator on Github.
  • Clone your OWN version of the repository in your terminal.
  • CD into the project base directory.
  • Download project dependencies by running npm install.
  • Start up the app using npm start.
  • Create a new branch: git checkout -b <firstName-lastName>.
  • Implement the project on your newly created <firstName-lastName> branch, committing changes regularly.
  • Push commits: git push origin <firstName-lastName>.

Test Runner

  • In a new terminal window, run npm test
  • With each saved change in your editor, the test runner will re-run all the tests
  • IMPORTANT If a test fails, use the test runner's error messages to find out why it is failing

Instructions and/or completion requirements (MVP)

In order to complete your mission for today, you will need to write tests to help you feel confident in shipping this component. Below is a general outline of how to accomplish this.

  1. Take a good amount of time to use the form. Find out what behaviors you expect, and any you don't expect. (Don't fix unexpected behaviors yet. We want our test to show us what's wrong in the UI, then fix the behavior - we'll walk you through that down below)
  2. Write down on a piece of paper what you want to test. (This is a very important step - always plan before coding!)
  3. Add your first test. This one should be a very simple test to make sure the testing setup is working.
  4. Write a sufficient amount of tests to give you confidence in the project's code

If you come across any "unexpected" behaviors in the form UI (not the test), try this flow:

  • You may have noticed that the form validation for one of the inputs is a little off...
  • Write a test for the "expected" behavior (it will fail because something in the component is doing something unexpected)
  • Confirm that the test fails, because of the "unexpected" behavior
  • Look at the code in the project to find what is causing the behavior
  • Fix the code so that your new test passes
  • Celebrate that your test helped you find and fix a bug!

Stretch goals

  • Using the REQ|RES API, build out a POST request in the form.

  • Add more elements to the form - eg dropdown, checkbox, etc

    • Add tests to include the new form elements

react-testing-contact-form's People

Contributors

dustinmyers avatar dustinmyers111 avatar ladrillo avatar worksofhart avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.