Skip to content

API Automation Testing using Javascript with Supertest & Mocha

Notifications You must be signed in to change notification settings

Darana-Henry/api-testing-with-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SVG Banners

💻 Tech Stack:

Frameworks and Libraries:

SuperTest Mocha Chai Reporting JavaScript Babel Faker JS DotEnv

Getting Started

Prerequisites

Make sure you have the following installed:

Installation

Welcome! To get started with this project, follow these steps:

  1. Clone the Repository

    git clone https://github.com/Darana-Henry/api-testing-with-javascript.git   
    
  2. Install Dependencies

    npm i
  3. Obtain API Token

    • Go to the GoRest Website.
    • Create a login account.
    • Once logged in, get the generated API token.
  4. Create a .env File

    • In the root directory, create a file named .env.
    • Add the following property to the .env file:
      USER_TOKEN=your_generated_api_token

Note:You only get the token after you log in. Do not share this token.

How to Run Tests

You have two options to run the tests for this project:

  1. Console Output Only

    • Run the following command to see the test results in your console:
      npm test
    • Console Output
  2. Console Output with HTML Report

    • Run the following command to see the test results in your console and generate an HTML report:
      npm run test-with-report
    • HTML Report
  3. JUnit Report for Jenkins

    • If you run with Jenkins, and use JUnit Report to publish your reports, you can run:

      npm run test-with-junit
    • This will run the tests and output a file named test-results.xml in the root folder.

    • Note: This won't output anything on the console. So it might feel like the test is stuck, but actually it's running in the background.

    • HTML Report

Example Usage

Console Output Only

$ npm test

Releases

No releases published

Packages

No packages published