The purpose of this repo is to give you some experience writing tests using the Jest testing library. You can check out their documentation any time if there's anything you need to know.
We haven't included the testing library in this project. In fact, we haven't set up the project at all. Your first challenge is to follow these instructions to get everything set up:
- Open a terminal in the root of this repo and run
This will turn the folder into an npm project, meaning we can install libraries easily. You should see a
npm init
node_modules
folder appear along with apackage.json
. - To install Jest, run
This downloads and installs Jest, which is the testing library we will be using.
npm install -D jest
- Open
package.json
and find "scripts". You should see a script called "test". Replace the contents of the "test" script with "jest".
You can now run any tests you write by running
npm run test
in the terminal.
Make a folder called tests
in the root of the project. If you want to test a file called calculator.js
you should create a file called calculator.test.js
and write your tests in there.
In the src
directory, you will find several files. These files contain the model solutions for the exercises you have been doing recently. Your task is to write tests which ensure the correctness of the code.