The software testing in Lab 8

 This week we start to practice how to test the project with a testing framework. In the lab, I choose Jest to test my link checker project written by JavaScript. Jest is a testing framework developed by Facebook. Originally designed to make UI testing easier for React developers, it’s now a full standalone suite of tools for any type of JavaScript project (including Node.js) and includes features such as a built-in assertion library, code coverage, and mocking. Jest also runs multiple test suites concurrently, which can speed up the overall testing process. Jest has a lot of advantages, so I want to use it.

First of all, I install the Jest to my local project using the command "npm install --save-dev jest". Then I write three unit tests for reading a file and requesting a url by creating two new .test.js files. After completing the coding, I try to test them using the command "npm run test" and it works well.

Unit test


Second, I add some scripts in the package.json file. After that, I can use the command "npm test" to start the project test and the command "npm coverage" to create a coverage analysis test report. 

                                            Add Test and Code Coverage Analysis


Third, I add the Continuous Integration using GitHub Actions. I choose to use the Node.js CI. After doing it, the GitHub will test the project automatically when I update my local code to my main branch in GitHub or other parters pull a request to it.

Forth, I modify some code and promote my project. Then, I pull a request to test my CI test.

Test CI


At last, I update the testing details to my CONTRIBUTING.md file so that other partners can better use the test tools.





Comments

Popular posts from this blog

Choose a project in Release 0.4

Open source development course

Publish project in Lab 9