Hi There
This week lab’s goal is to test out our SSG.
We were instructed to use a tester like Jest to test our code and check if everything is working as intended.
Jest
I choose Jest for my project as I am using JS.
It was fairly simple to use, and because I have used it before with David in previous Web courses, I knew already what I was supposed to do.
Installing
Jest was fairly simple and intuitive, I followed the Documentation to install it.
First I did:
npm install --save-dev jest
Then I created a tester file for one of my functions.
In this tester file I did a series of small tests as instructed and tried to reach all conditions available in that function.
After that, I did some tests to test the core of my SSG.
Because I had a main function where the main action happened, it was fairly simple to do and I didn’t have to refactor my code.
Testing
To run all tests at once, I did a script as mentioned on the Documentation
"scripts": {
"test": "jest",
…
This way it run all the tests I made automatically.
Thank you for reading!
Top comments (0)