demo-rail

Test framework for automating rest api & JS & typescript!

Usage no npm install needed!

<script type="module">
  import demoRail from 'https://cdn.skypack.dev/demo-rail';
</script>

README

Rest-Assured tool, it supports both TypeScript and JavaScript

you can use with other frameworks such as cucumber, mocha, jest etc

Integrated with cucumber report

Upcoming features

  • testrail integrations
  • https://www.npmjs.com/package/testrail-integration
  • New JSON response utils to validate search filters,
  • Getting Server timestamps based on TimeZone
  • More handy json validations(ex: sorting ,date,limit, offset validations etc) for search filters(any GET call) without writing asserts

Highlights

  • This API automation tool designed to support API automation like other tools Postman, RestAssured and Karate
  • It supports CommonJS, ES6 and TypeScript
  • Pretty easy to use this library for non JavaScript developers as well
  • It supports Cucumber, Mocha and other frameworks as well
  • This tool helps integration testing with webui , mobile and other applications
  • It helps API integration (example : to automate combination of promo, tax and price services) testing as well.
  • Best feature, Chai asserts are supported implicitly for json response validations
  • Easy to find json paths and node values like https://jsonpath.com/
  • Easy to externalize test data request and response json files
  • Supports huge jsons request and responses
  • Can send json request body as File and String
  • where Include or exclude parameters from the request body for the negative testing
  • Mutations on JSON objects where Dynamic parameters can be applied on json objects
  • Can send full json response as file for complete json schema validations
  • Https API
  • Promise API
  • Handled exceptions internally
  • Easy to use Request API's with basic knowledge of javascript and typescript
  • Going to add more utils for json validation to meet API's functionality
  • it supports fixtures similar to https://www.npmjs.com/package/fixtures
  • Actively maintained

Extra features: Chai asserts supported implicitly for json response validations Passing request body as json file , full json response validation as file for complete schema validations. It supports json path validations

|json path|value| |username| myname| using exact path : example: |json path|value| |data[*].username| myname|

Easy way of automation

making request of api end point Same method can be used for GET(Default), PUT,POST, PATCH, DELETE

Below package also contains same methods except few https://www.npmjs.com/package/cucumberjs-rest-assured

More documentation will be added, refer github links clone and execute sample code snippets

Please refer github links for code snippets , these methods can be used for mocha and other frameworks as well contact letautomate@gmail.com , let.automate@gmail.com krishna01012002@gmail.com

Note : in case error for tunnel

npm i tunnel --save-dev npm i @types/tunnel

Proxy support

Use your proxy details if needed https://github.com/koichik/node-tunnel

 response = await restRequest("https://gorest.co.in/public-api/users", {
    headerOptions: JSON.parse(headerOptions),
    httpMethod: "GET", timeOut: 20000,
    agent: tunnel.httpOverHttp({
                proxy: {
                    host: 'localhost',
                    port: '8080',
                    headers: {
                    'User-Agent': 'Node'
                    } 
            })
  });

Access token

Note: You can keep request body in json file as well and replace user name and passwords from env or config files
const requestBodyAsJsonString: string = JSON.stringify({
  "grant_type": "password",
  "username": "{username}",
  "password": "{password}",
  "client_id": "localhost-dev"
});

const headerOptions: string = JSON.stringify({"Content-Type": "application/x-www-form-urlencoded"});

 response = await restRequest("https://gorest.co.in/public-api/users", {
    headerOptions: JSON.parse(headerOptions),
    httpMethod: "POST", inputBody: requestBodyAsJsonString,
    formFlag: true, timeOut: 10000
  });

License

Please see LICENSE.md.