✏ Using the jest framework to create the first code tests.
Open repository:
- Open this repository in Gitpod and wait until LearnPack is loaded.
- Follow the LearnPack Instructions (run learnpack start in the terminal if instructions are not showed).
Run the exercise:
- Initialize the project (this creates a package.json file in the project root):
$ npm init -y
- Install Jest:
$ npm install jest --save
-
Open the package.json file and write jest --detectOpenHandles in the scripts -> test node (instead of "echo "Error: no test specified" && exit 1").
-
Run the next command to test:
$ npm run test
- The exercise files are app.js and test.js (in the test folder)
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 |
https://learn.breatheco.de/course/full-stack.v4/12/p/unit-test-with-jest
https://github.com/breatheco-de/exercise-unit-test-with-jest
💻 Jose Clemente García Rodríguez (https://github.com/m4n50n)