codeceptjs-http
CodeceptJS helper for HTTP request with Mochawesome logging
Last updated a month ago by kronoslive .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install codeceptjs-http 
SYNC missed versions from official npm registry.

codeceptjs-http

codeceptjs-http is CodeceptJS helper which wraps then-request library to process HTTP requests. It's alternative helper that provides more flexible request management.

NPM package: https://www.npmjs.com/package/codeceptjs-http

Configuration

This helper should be configured in codecept.json/codecept.conf.js

  • endpoint: base HTTP url.

Example:

{
   "helpers": {
     "HTTP" : {
       "require": "codeceptjs-http",
       "endpoint": "http://localhost:8080"
     }
   }
}

sendRequest

Send HTTP request, response will be availible as return value and in this.currentResponse.

I.sendRequest(('/callback', 'POST', {
                    headers: {
                      'Content-Type': 'application/json',
                    },
                    json: {
                      myParam: 123
                    },
                  })); // will use base endpoint
I.sendRequest('https://logalhost:8080/getOrders', 'GET'); // will use url from 1st argument

Parameters

  • requestPath - endpoint path. Can be relative or absolute
  • method - (optional) request method. Default 'GET'
  • options - (optional) headers, body, etc. see https://www.npmjs.com/package/then-request
  • domain - (optional) change domain for request

seeHttpResponseHasValidJsonSchema

Validate that latest https response has specified JSON schema.

I.seeHttpResponseHasValidJsonSchema('api/getOrders.json');
I.seeHttpResponseHasValidJsonSchema('filters/values.js', ['param1', 'param2']);

Parameters

  • schema - path to JSON schema file. is relative to schemas folder. schemas folder will be in codeceptJS root folder (path.join(global.codecept_dir, './schemas/'))
  • params - (optional) if schema file is js file, that export function, then you can specify here params in array, that will be applied to this function. Function should return JSON schema.
  • data - (optional) specify data that should be validated. By default first response message for latest request

Current Tags

  • 0.0.6                                ...           latest (a month ago)

6 Versions

  • 0.0.6                                ...           a month ago
  • 0.0.5                                ...           a year ago
  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 13
Dependencies (4)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |