/unit_testing_with_jest

Unit testing code with Jest | 4Geeks Academy

Primary LanguageJavaScript

4Geeks Logo Unit testing with Jest

Using the jest framework to create the first code tests.

Instructions 📄

Open repository:

  1. Open this repository in Gitpod and wait until LearnPack is loaded.
  2. Follow the LearnPack Instructions (run learnpack start in the terminal if instructions are not showed).

Run the exercise:

  1. Initialize the project (this creates a package.json file in the project root):
$ npm init -y
  1. Install Jest:
$ npm install jest --save
  1. Open the package.json file and write jest --detectOpenHandles in the scripts -> test node (instead of "echo "Error: no test specified" && exit 1").

  2. Run the next command to test:

$ npm run test
  1. The exercise files are app.js and test.js (in the test folder)

What is this exercise about ❓

We are going to be using the Jest library to build a program capable of converting numeric values from one currency to another:

Function name Description
fromDollarToYen Receives a dollar amount and returns equivalent amount in Japan Yen
fromEuroToDollar Receives a Euro amount and returns equivalent amount in US Dollar
fromYenToPound Reveives a Yen amount and equivalent amount in England Pound

Sources 📌

https://learn.breatheco.de/course/full-stack.v4/12/p/unit-test-with-jest

https://github.com/breatheco-de/exercise-unit-test-with-jest

https://jestjs.io/

💻 Jose Clemente García Rodríguez (https://github.com/m4n50n)