Coder Social home page Coder Social logo

gistsapi's Introduction

Automated API Testing

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.

Frameworks

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

Github Actions

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

Test Scenarios

Following test scenarios were covered

  • Unauthenticated
    • Read Gists
    • Read Specific Gist (Public)
  • Authenticated
    • Create Gist
    • Read Gist
    • Update Gist
    • Delete Gist

Following Negative scenarios were also covered

  • Unauthorized request 401
  • Unprocessable entity 422
  • Not Found 404

Steps to execute

  • Pre-requisite

    • node.js should be installed on the system.
  • Setup

    • 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.
  • Execute tests on Local

    • 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 folder

      TOKEN=${YOUR_TOKEN} npm run test:awesome

    • Tests can also be run individually as

      TOKEN=${YOUR_TOKEN} npx mocha tests/test.js -g '${TEST_NAME}'

  • Execute tests on Github actions

    • 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.

gistsapi's People

Contributors

adiparab14 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.