DEV Community

Hung Nguyen
Hung Nguyen

Posted on

4 2

Testing for Static Site Generator

Testing for OSDSSG

New testing system has been added to OSD600-SSG. This feature will be beneficial for the current developers to prevent bugs that might happen and for future contributers who would like to test the tool.

Framework

Jest is a JavaScript testing framework that allow you to write approachable API that gives quick results. Its syntax is simple and new user-friendly. On top of that, Jest does not require complicated configuration which will let you do the tests faster.

Set up

To install:
npm install --save-dev jest
In package.json I create a script that will jest called test so test can be run by:

npm run test 

npm run test <folder name or file name>
Enter fullscreen mode Exit fullscreen mode

Note: Before create any test, create a folder name test and put test files to it.

Process

I created a new branch called testing. After setting up Jest, I created 2 big tests, one that would test command-line that users pass in the terminal, and the other one would test the function that convert markdown files. I wrote my test as details as possible. Example, I wrote tests for every if-else:
Image description
Also provided a lot of input type (null, 1-line, multiple lines) for testing the markdown converter function:
Image description
This helped me a lot since I realized that I made a lot of mistakes, one of those was in my if statement (&& instead of ||). After all tests were passed, I commit and push my final version to main.

Links

Repo: https://github.com/nguyenhung15913/OSD600-SSG
Jest: https://jestjs.io/

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post