Tutorials

Test with Jest

 Test with Jest   Free Tutorial Download

What testing means?

In tech jargon testing means checking that our code meets some expectations. For example: a function called “transformer” should returns the expected output given some input.

There are many types of testing and soon you’ll be overwhelmed by the terminology, but long story short tests fall into three main categories:

  • unit testing
  • integration testing
  • UI testing

In this Jest tutorial we’ll cover only unit testing, but at the end of the article you’ll find resources for the other types of tests.

Jest Tutorial: what is Jest?

Jest is a JavaScript test runner, that is, a JavaScript library for creating, running, and structuring tests.

Jest ships as an NPM package, you can install it in any JavaScript project. Jest is one of the most popular test runner these days, and the default choice for React projects.

First things first: how do I know what to test?

When it comes to testing, even a simple block of code could paralyze beginners. The most common question is “How do I know what to test?”.

If you’re writing a web application a good starting point would be testing every page of the app and every user interaction. But, web applications are also made of units of code like functions and modules that need to be tested too.

There are two scenarios most of the times:

  • you inherit legacy code which comes without tests
  • you have to implement a new functionality out of thin air

What to do? For both cases you can help yourself by thinking of tests as of bits of code that check if a given function produces the expected result. Here’s how a typical test flow looks like:

  1. import the function to test
  2. give an input to the function
  3. define what to expect as the output
  4. check if the function produces the expected output

Really, that’s it. Testing won’t be scary anymore if you think in these terms: input – expected output – assert the result.

Now hands on Jest!

 

Download Test with Jest   Free

https://xmbaylorschool-my.sharepoint.com/:u:/g/personal/mossh_baylorschool_org2/EbakA5C9BVtBqru8b1PbL6oB6aMEdvcoNH2LXnwzsVNw0A
https://anonfiles.com/taw2VcLao7
https://drive.google.com/file/d/14S9nHqzDbsjKkf3Aduv3ikUUyukfzmp8/view?usp=sharing
https://uptobox.com/qt37igc7cqgq

Password : freetuts.download

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also

Close
Back to top button