1.0.0 • Published 4 years ago

qester-cli v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

gester-cli

Gester is a GraphQL test automation that accepts a yaml config file and parses GraphQL queries.

Config

Config is a yaml file that contains definitions and steps of the test automation.

Variable resolution: When there is a string value that contains this form {{x.y.z}}, the value will be resolved by it's corresponding value.

version

This holds the version of the config current acceptable value is 1.

url (optional)

The default value of the url for the request to be made.

vars

Contains the variables that will be used through the application. It's advised to use vars for constant value that will be used throughout the config. Values being stored on vars are access through root context.

example:

url: http://someurl/graphql

Resolving the value will be through {{url}}

defs

This is more likely the how vars work, but it's suggested to put all definitions that contains variables values. The root context will be defs.

example:

defs:
  account:
    username: johndoe
    password: easypass

Resolving the value will be through {{defs.account}}

tasks

Tasks is an array that accepts an object that contains the steps.

  • request (required) - the name of the request, this is mapped to the matution/query name.
  • url (optional) - the host url where the request will be going to be sent
  • options (optional) - the options to be included upon sending the request. Here is the list of possible options:

    • headers: Header to be included for the request
  • vars (optional): variables that will be used by the GraphQL.

  • as (optional): When this is present the response will be saved to the response object. ie. Considering the as field is being set to account you can access the response with variable resolution {{response.account}}.

Example

graphql/account.gql

mutation ($username: String!, $password: String) {
  createAccount(username: $username, password: $password)
}

###
mutation ($id: ID!, $password: String!) {
  updatePassword(id: $id, password: $password)
}

config/account.yaml

version: 1
vars:
  username: johndoe

host: http://localhost:3000/graphql

defs:
  oldPassword: easypassword
  newPassword: hardpassword
tasks:
  updateAccount:
    - request: createAccount
      vars:
        username: {{username}}
        password: "{{defs.oldPassword}}"
      as: account
    - request: updatePassword
      vars:
        id: "{{response.account.createAccount}}"
        password: "{{defs.newPassword}}"

To execute the steps on updateAccount task. Run the command:

gester -c config/account.yml -t updateAccount -f graphql

Upon executing the command, it will generate a log file that contains the payload being sent to the server and the response.