Automated API Tests for Github Gists API were implemented as part of this project. The documentation for the API is available here. This test framework was developed with SuperTest, Mocha, Chai and Javascript.
Following frameworks were used to implement the test tests
- SuperTest provides a high level absctraction for the HTTP requests
- Mocha is a javascript testing framework
- Chai is used as the assertion library
- Mochawesome is a report generator for the Mocha testing framework
The tests are also executed as part of Continuous Integration using Github Actions.
The configuration file for the same is available here .github/workflows/node.js.yml
- Unauthenticated
- Read Gists
- Read Specific Gist (Public)
- Authenticated
- Create Gist
- Read Gist
- Update Gist
- Delete Gist
- Unauthorized request
401
- Unprocessable entity
422
- Not Found
404
-
node.js
should be installed on the system.
-
- Some of the test require an authenticated user to trigger the requests. Authetication token can be generated from Github account as shown here. As these tests are only for gists, it is enough to limit the access of the token to gist.
- Run
npm install
to install node modules.
-
-
To execute all the tests without a test report
TOKEN=${YOUR_TOKEN} npm run test
-
To execute all the tests using the mochawesome reporter. HTML and JSON reports will be available in the
mochawesome-report
folderTOKEN=${YOUR_TOKEN} npm run test:awesome
-
Tests can also be run individually as
TOKEN=${YOUR_TOKEN} npx mocha tests/test.js -g '${TEST_NAME}'
-
-
- Fork the repository
- For the forked respository, create an secret as per steps here. Add personal token in the variable
TOKEN
- Now trigger the Gists API Test workflow from Github Actions.