Skip to content

Instantly share code, notes, and snippets.

@jparciga
Last active October 25, 2021 20:27
Show Gist options
  • Save jparciga/ed01f19c3938d05f2bcb3d7c3e42f7e9 to your computer and use it in GitHub Desktop.
Save jparciga/ed01f19c3938d05f2bcb3d7c3e42f7e9 to your computer and use it in GitHub Desktop.
Mini-Challenge 2: Intro to Testing

Mini-Challenge 2: Intro to Testing

Answer the following questions first

  1. Using create-react-app, what do we need to set up for testing?
  2. What components are worth to test in your development?
  3. Can you apply TDD once you already created components?

The Challenge

NOTE: Apply TDD as much as you can.

  1. Find any sub-routine, extract that logic into a separate file and test it out.
  2. Run test coverage and save results into a .txt file at ./ - root level. Can you make the total coverage to be above of 60%?

Acceptance Criteria

  • Meaningful test cases were implemented for components and sub-routines logic.
  • All the test cases were successful.

Bonus Points

  • Test coverage is above 60%.
@prateekvarma
Copy link

  1. create-react-app comes pre-built with testing tools, all you have to do is install them via NPM or Yarn.
  2. For this challenge, i've tested fetching the API data and matching them on the HTML elements (like, title and description)
  3. No, TDD is done during the development process, and not after. But you can always do standard testing after development if required.

@lucapame
Copy link

  1. Using create-react-app, what do we need to set up for testing?
    Nothing much since it already comes with Jest ready to start testing.
  2. What components are worth testing in your development?
    In my opinion, the ones that have key features or are more dynamic when using the app, you need to keep in mind that you need to test
    that all renders properly and test the props and latest on those components
  3. Can you apply TDD once you already created components?
    That depends on the perspective of each developer, in my opinion, yes, you can start doing TDD on code that was already written but is always good practice to do it starting the development process

@jazzcelaya
Copy link

1. Using create-react-app, what do we need to set up for testing?

I believe it already includes Jest, so we-re all set up!

2. What components are worth to test in your development?

I think that those that are going to deal with different kinds of inputs, specially those that come from the final user, are very important, so the events. Also checking that it renders properly, the props are passed correctly and the edge cases are quite worth the effort in my opinion.

3. Can you apply TDD once you already created components?

I don't think it can be done retroactively but, if needed, we can include it in further iterations of a product.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment