Giter Club home page Giter Club logo

supertest_poc's Introduction

API Testing using SuperTest, Mocha and Chai

Open Source Love License Node.js CI

Don't forget to give a โญ to make the project popular.

What is it all about?

I have been using Rest-Assured framework all the time for testing APIs with Java. But this time it was my project's demand to perform API testing in Javascript. Being a newbie to JS, I googled for some tools and found SuperTest. To introduce SuperTest, it is a high level abstraction of HTTP requests, making it perfect for testing APIs. I decided to do a POC of this tool to understand it better, hence this project was created. I thought of sharing this on github, so it helps others as well who want to learn more about this tool. Checkout this link to learn more about SuperTest

Getting Started:

You need to have the following installed in your machine:

  1. Node (Latest Version).
  2. npm(Latest Version).
  3. mocha framework is used for writing tests and chai for assertions, following command should help to install the required npm packages: npm i -D -g supertest mocha chai mochawesome
  4. For running the tests, you need to type the command: npm run test. (Check Package.json for more details)
  5. For generating the mochawesome report, run the command npm run report (Check Package.json for more details.) It will generate and export the report in mochawesome-report folder from which you can open the index.html file to view the report.

Talking more about the Scenarios Covered in this project:

  • I have covered, GET, POST, PUT, PATCH and DELETE requests. You will find the example code in the test folder of the repository.

  • End to End scenarios have been added for the restful booker APIs. If you need to get into more details about how to write tests using supertest, mocha and chai?, this blog is all you need to refer and get started.

  • Mochawesome reporter is used to generate the reports and show summary of the tests. I found it quite useful report as it shows the test description alongwith the tests and the time taken to run the tests.

โ“ Need Assistance?

  • Discuss your queries by writing to me @ [email protected] OR ping me on any of the social media sites using the below link:

๐Ÿš€ Trainings and Guidance

  • Contact me for 1:1 trainings/guidance for Software Testing, Mock Interviews, Test Automation tools queries, Mentoring and Coaching.

๐Ÿ’ญ Checkout the blogs related to Software Testing on my website

supertest_poc's People

Contributors

mfaisalkhatri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

supertest_poc's Issues

Create e2e tests using restful booker.

Following steps needs to be automated

  1. Create a Booking.
  2. Save the Booking Id from create booking response.
  3. Get Booking using the id in step 2 and compare with the create booking response.
  4. Create auth token method
  5. Update the booking dates and total price using the id in step 2 and auth token in step 4.
  6. Assert the response of update booking
  7. Update the fisrtname and last name using the Patch request and assert the response.
  8. Delete the booking and assert the status code and response.
  9. Get the Booking Id which is deleted(Booking Id from Step 2).

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.