Star

Created With

linkValidation Overview



linkGeneral Assertions

These assertions work similary for cookies & headers.

See also:



linkExact Value

Assert some property matches an exact literal value.

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link headers:

7link - name: content-type

8link value: application/json

9link cookies:

10link - name: x-xsrf-token

11link value: 4f3b2209-3b75-4a8a-bd10-d0b8f02a9c07



linkRegular Expression

Assert some property matches a regular expression.

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link headers:

7link - name: content-type

8link value: !!js/regexp /json/

9link cookies:

10link - name: x-xsrf-token

11link value: !!js/regexp /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/



linkCustom Validator

Write custom code to do your own assertions.

Functions context is bound to the spec context, so this.response has all the relevant properties.

Properties:



linkInline JS Function

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link status_code: 200

7link custom_validator:

8link run_type: inline

9link inline:

10link function: !!js/function >

11link function() {

12link var users = JSON.parse(this.response.body);

13link if (!users.length) {

14link throw new Error('no users found');

15link }

16link if (users[0].firstName !== 'john') {

17link throw new Error('first user in list is not john');

18link }

19link if (this.response.duration > 2000) {

20link throw new Error('request took longer than expected');

21link }

22link }



linkJS Module

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link status_code: 200

7link custom_validator:

8link run_type: module

9link module:

10link module_path: lib/helpers/path-to-a-file.js

11link function_name: validateUsersList



Validation OverviewGeneral AssertionsExact ValueRegular ExpressionCustom ValidatorInline JS FunctionJS Module

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right

Status Code Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right