Skip to content

Simplified automated Loopback 3 API Testing with 'realm' users

License

Notifications You must be signed in to change notification settings

Monstrik/loopback-api-testing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loopback 3 API Testing with 'realm' users

This package is a simplified replacement for loopback-testing, which is now considered deprecated. It generates Mocha tests for Loopback API routes and examines their response codes. Optimized for Loopback 3 with realm

The main difference between this package and loopback-testing is that loopback-api-testing does not require you to write any code. Tests are specified in json format and the tests are generated automatically.

This package is not supported by, endorsed by, or associated with Strongloop or the core Loopback team.

Installing

npm i https://github.com/Monstrik/loopback-api-testing.git
npm i mocha -g

Example Usage

cd api-test-example
npm i
npm test

Running the tests (for example):

mocha --reporter spec test

Making Authenticated Requests

You can specify a username and password in your tests to make the request as an authenticated user.

[
  {
    "method": "GET",
    "path": "Model",
    "email": "my@user.com",
    "password": "myPassword",
    "realm":"REALM1"
    "expect": 200
  }
]

Making Requests with Data

You can send json data with a request.

[
  {
    "method": "POST",
    "model": "Cars",
    "withData": {
      "color": "blue"
    },
    "expect": 200
  }
]

Making Requests with query param

You can add userId in query with a request.

api/customers/{currentUserId}?auth...

[
   {
        "method": "PATCH",
        "path": "api/customers/",
        "password": "TestUser@TestUser.com",
        "realm": "SUYC",
        "email": "TestUser@TestUser.com",
        "withPathValues": [
          "{currentUserId}"
        ],
        "withData": {
          "FirstName": "NewName2"
        },
        "expect": 200
      }
]

About

Simplified automated Loopback 3 API Testing with 'realm' users

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%