diff --git a/docs/basics/config.html b/docs/basics/config.html index 302bef6..5ac9dbc 100644 --- a/docs/basics/config.html +++ b/docs/basics/config.html @@ -41,43 +41,43 @@

linkJS Inline Async function

See also:

1linkconfiguration:

2link host: yourcompany.com

3link scheme: https

4link port: 443

5link base_path: /api

6link custom_configuration:

7link run_type: inline

8link inline:

9link function: !js/asyncFunction >

10link async function() {

11link this.scheme = 'http';

12link this.port = 3027;

13link }

14link# https//yourcompany.com:3027/api


-

linkJS Module

See also:

1linkconfiguration:

2link host: yourcompany.com

3link scheme: https

4link port: 443

5link base_path: /api

6link custom_configuration:

7link run_type: module

8link module:

9link module_path: config/test.js

10link function_name: configureForEnv # --> 'this'bound to suite object, e.g. this.host, this.port, etc.

Spec Config Sectionschemehostportbase_pathcustom_configurationJS Inline FunctionJS Inline Async functionJS Module

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkJS Module

See also:

1linkconfiguration:

2link host: yourcompany.com

3link scheme: https

4link port: 443

5link base_path: /api

6link custom_configuration:

7link run_type: module

8link module:

9link module_path: config/test.js

10link function_name: configureForEnv # --> 'this'bound to suite object, e.g. this.host, this.port, etc.

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/basics/meta.html b/docs/basics/meta.html index dec65cc..2e3fb60 100644 --- a/docs/basics/meta.html +++ b/docs/basics/meta.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkSpec Meta Section

Optional section providing info related to the entire suite

⚠️ Note: applies to every file path in the suite

example-spec.yml
1linkmeta:

2link name: Make sure Google loads

3link locate_files_relative: true

4linkconfiguration:

5link host: www.google.com

6link scheme: https

7linkspecs:

8link - name: Fetch Google homepage

9link request:

10link method: get

11link path: /

12link response:

13link status_code: 200



linkname

  • Type: string required
  • Default: null

Give a name that describes the suite (e.g: "New User registration")

linkenabled

  • Type: boolean optional
  • Default: true
  • Values: true, false

Enable/disable whether this suite should be run.

See also: Example: Disabled Suite

linklocate_files_relative

  • Type: boolean optional
  • Default: false
  • Values: true, false

Locate specified files relative to this suite file's path.

If false, locates files relative to Node process's current working directory.

If true, locates files relative to the suite's path.

See also: Example: Relative Intersuite Dependencies

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkSpec Meta Section

Optional section providing info related to the entire suite

⚠️ Note: applies to every file path in the suite

example-spec.yml
1linkmeta:

2link name: Make sure Google loads

3link locate_files_relative: true

4linkconfiguration:

5link host: www.google.com

6link scheme: https

7linkspecs:

8link - name: Fetch Google homepage

9link request:

10link method: get

11link path: /

12link response:

13link status_code: 200



linkname

  • Type: string required
  • Default: null

Give a name that describes the suite (e.g: "New User registration")

linkenabled

  • Type: boolean optional
  • Default: true
  • Values: true, false

Enable/disable whether this suite should be run.

See also: Example: Disabled Suite

linklocate_files_relative

  • Type: boolean optional
  • Default: false
  • Values: true, false

Locate specified files relative to this suite file's path.

If false, locates files relative to Node process's current working directory.

If true, locates files relative to the suite's path.

See also: Example: Relative Intersuite Dependencies

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/basics/overview.html b/docs/basics/overview.html index ceb8ee8..02ea63b 100644 --- a/docs/basics/overview.html +++ b/docs/basics/overview.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkSpec Overview & Basic Concepts

REST-EZ's lets you test HTTP-based APIs without code (declarative, instead of procedural). It aims to make API testing easy, free, and fast for everyone.

linkThe High-level View

  • suite - a yaml file that includes a list of one or more specs
  • spec - block that defines a request & response dialog, with optional assertions and lifecycle hooks

You can write custom JS including external JS files.

linkRequired Sections

A test suite has three required sections:

linkOptional Sections

Optional sections are:

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkSpec Overview & Basic Concepts

REST-EZ's lets you test HTTP-based APIs without code (declarative, instead of procedural). It aims to make API testing easy, free, and fast for everyone.

linkThe High-level View

  • suite - a yaml file that includes a list of one or more specs
  • spec - block that defines a request & response dialog, with optional assertions and lifecycle hooks

You can write custom JS including external JS files.

linkRequired Sections

A test suite has three required sections:

linkOptional Sections

Optional sections are:

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/basics/specs.html b/docs/basics/specs.html index e1cfce4..926e1ff 100644 --- a/docs/basics/specs.html +++ b/docs/basics/specs.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkSpecs Section

Required section that provides a list of individual HTTP requests to run.

  • Type: array required
  • Example: (see below)

⚠️ Note: at least one spec is required for the suite to be valid.

specs/star-wars-service.yml
1linkmeta:

2link name: Star Wars suite

3linkconfiguration:

4link scheme: https

5link host: swapi.dev

6link base_path: /api

7linkspecs:

8link - name: Fetch info about Luke Skywalker

9link request:

10link path: /people/1/

11link method: get

12link accept: application/json

13link response:

14link status_code: 200

15link headers:

16link - name: content-type

17link value: !!js/regexp application/json

18link json_data:

19link - path: $.name

20link value: Luke Skywalker

21link after_test:

22link run_type: inline

23link inline:

24link function: !!js/function >

25link function() {

26link this.suite.person = JSON.parse(this.response.body);

27link }

28link - name: Fetch each movie that Luke Skywalker is in

29link loop:

30link type: dynamic

31link dynamic:

32link run_type: inline

33link inline:

34link function: !!js/function >

35link function() {

36link return this.suite.person.films;

37link }

38link before_test:

39link run_type: inline

40link inline:

41link function: !!js/function >

42link function() {

43link this.test.path_params = {

44link id : this.loopItem.match(/\/api\/films\/(\d+)\//)[1]

45link };

46link }

47link request:

48link path: /films/{id}/

49link method: get

50link accept: application/json

51link response:

52link status_code: 200

See also:



linkRetry

Use the retry spec level property to automatically retry the spec. Example use case is polling a job until in completed state after a while.

linkcount

  • Type: integer required
  • Example: 2

How many times to retry this spec.

linkwait_before_each

  • Type: integer optional
  • Example: 10
  • Values: http, https

Number of milliseconds (ms) between retry attempts.

1link - request:

2link path: /status

3link method: get

4link retry:

5link count: 3

6link wait_before_each: 10

7link response:

8link status_code: 200

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkSpecs Section

Required section that provides a list of individual HTTP requests to run.

  • Type: array required
  • Example: (see below)

⚠️ Note: at least one spec is required for the suite to be valid.

specs/star-wars-service.yml
1linkmeta:

2link name: Star Wars suite

3linkconfiguration:

4link scheme: https

5link host: swapi.dev

6link base_path: /api

7linkspecs:

8link - name: Fetch info about Luke Skywalker

9link request:

10link path: /people/1/

11link method: get

12link accept: application/json

13link response:

14link status_code: 200

15link headers:

16link - name: content-type

17link value: !!js/regexp application/json

18link json_data:

19link - path: $.name

20link value: Luke Skywalker

21link after_test:

22link run_type: inline

23link inline:

24link function: !!js/function >

25link function() {

26link this.suite.person = JSON.parse(this.response.body);

27link }

28link - name: Fetch each movie that Luke Skywalker is in

29link loop:

30link type: dynamic

31link dynamic:

32link run_type: inline

33link inline:

34link function: !!js/function >

35link function() {

36link return this.suite.person.films;

37link }

38link before_test:

39link run_type: inline

40link inline:

41link function: !!js/function >

42link function() {

43link this.test.path_params = {

44link id : this.loopItem.match(/\/api\/films\/(\d+)\//)[1]

45link };

46link }

47link request:

48link path: /films/{id}/

49link method: get

50link accept: application/json

51link response:

52link status_code: 200

See also:



linkRetry

Use the retry spec level property to automatically retry the spec. Example use case is polling a job until in completed state after a while.

linkcount

  • Type: integer required
  • Example: 2

How many times to retry this spec.

linkwait_before_each

  • Type: integer optional
  • Example: 10
  • Values: http, https

Number of milliseconds (ms) between retry attempts.

1link - request:

2link path: /status

3link method: get

4link retry:

5link count: 3

6link wait_before_each: 10

7link response:

8link status_code: 200

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/cli/basics.html b/docs/cli/basics.html index daf1281..ba41b71 100644 --- a/docs/cli/basics.html +++ b/docs/cli/basics.html @@ -37,43 +37,43 @@ }

linkCommand Line Interface (CLI)

Basic usage:

1link$rest-ez [options] <path(s)>

Invoke rest-ez from command-line:

1link$./node_modules/.bin/rest-ez

Test Suite path/pattern/directory is not specified, Looking for suites in specs directory No test suites found

By default REST-EZ looks for specs in the specs/ folder



linkDebugging

You can optionally log all info about failed requests using --reporter-options logRequests.

Log all failed requests in an HTML report:

1link$./node_modules/.bin/rest-ez --reporter html --reporter-options logRequests

Log all failed requests in a JSON report:

1link$./node_modules/.bin/rest-ez --reporter json --reporter-options logRequests

⚠️ Currently, use of logRequests option only works with a reporter specified, as the example above.



linkRunning Suites in Parallel

When you have lots of test suites, it might take a while to execute all of them serially.

To reduce the test execution time, REST-EZ is built with parallelism. You can invoke rest-ez with --parallel option to trigger parallel execution mode. -All reporters respect parallel mode and generate correct reports with properly mapped errors if any.

This is how you can execute suites in parallel with rest-ez

1link$./node_modules/.bin/rest-ez --parallel 8

Above command will start test execution in parallel mode with 8 suites at a time.

⚠️ NOTE: maximum number of suites supported in parallel is 24



Home

Getting Startedchevron_right
Basicschevron_right

Overview +All reporters respect parallel mode and generate correct reports with properly mapped errors if any.

This is how you can execute suites in parallel with rest-ez

1link$./node_modules/.bin/rest-ez --parallel 8

Above command will start test execution in parallel mode with 8 suites at a time.

⚠️ NOTE: maximum number of suites supported in parallel is 24



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/cli/options.html b/docs/cli/options.html index 5aaeae0..bf35786 100644 --- a/docs/cli/options.html +++ b/docs/cli/options.html @@ -49,43 +49,43 @@ --recursive include sub directories when searching for suites --reporters display available reporters -h, --help output usage information -



Home

Getting Startedchevron_right
Basicschevron_right

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/cli/reporters.html b/docs/cli/reporters.html index b406461..346046b 100644 --- a/docs/cli/reporters.html +++ b/docs/cli/reporters.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkReporters

REST-EZ has several built-in reporters, json, specs, html etc.

When you need a HTML report, you can invoke rest-ez with the --reporter option

Basic example:

1link$./node_modules/.bin/rest-ez --reporter html

Advanced example:

1link$./node_modules/.bin/rest-ez --reporter html,json --reporter-options jsonReportDir=reports,jsonReportName=json-report,htmlReportDir=reports,htmlReportName=html-report,logRequests



linkMultiple Formats

REST-EZ can generate reports in multiple formats.

When you need a HTML report and a JSON report too, you could do something like this

1link$./node_modules/.bin/rest-ez --reporter html,json

This way you can generate reports in multiple formats for the same run.



linkReporter Options

REST-EZ accepts an additonal command line option --reporter-options that you can use to customize how and where reports are generated and saved.

You must pass a comma separated list of key and value pairs to this option as k=v,k2=v2,...



linkjsonReportDir

  • Type: string optional
  • Example: test-reports
  • Default: [cwd]

Provide an existing directory path that is relative to REST-EZ node process's cwd. JSON report will be saved to this directory.

1link$./node_modules/.bin/rest-ez --reporter json --reporter-options jsonReportDir=test-reports

# Outputs to: test-reports/report.json



linkjsonReportName

  • Type: string optional
  • Example: test-report.json
  • Default: report.json

Provide a name for the JSON report file. JSON report will be saved with this name.

1link$./node_modules/.bin/rest-ez --reporter json --reporter-options jsonReportName=test-report.json

# Outputs to: test-report.json



linkhtmlReportDir

  • Type: string optional
  • Example: test-reports/
  • Default: [cwd]

Provide an existing directory path that is relative to REST-EZ node process's cwd. HTML report will be saved to this directory.

1link$./node_modules/.bin/rest-ez --reporter json --reporter-options htmlReportDir=reports,htmlReportName=test-report.json

# Outputs to: reports/test-report.json



linkhtmlReportName

  • Type: string optional
  • Example: test-report.html
  • Default: report.html

Provide a name for the HTML report file. HTML report will be saved with this name.

1link$./node_modules/.bin/rest-ez --reporter json --reporter-options htmlReportDir=html-reports,htmlReportName=latest-report.json

# Outputs to: html-reports/latest-report.json



linklogRequests

  • Type: boolean optional
  • Example: true
  • Default: false (if not provided)

Tells REST-EZ to log HTTP request & response details in reports for failed tests. Omit this if you don't want to log details.

Log all failed requests in an HTML report:

1link$./node_modules/.bin/rest-ez --reporter html --reporter-options logRequests

Log all failed requests in a JSON report:

1link$./node_modules/.bin/rest-ez --reporter json --reporter-options logRequests



linkCustom Reporters

You can write your own custom reporter.

See also: REST-EZ Built-In JSON Reporter

Reporters are JS constructors. When instantiated, a reporter receives the test launcher object along with program options.

linkRunning Custom Reporter

Using a node module by name:

1link$./node_modules/.bin/rest-ez --reporter html,custom-reporter-module-name

Using a path to a file:

1link$./node_modules/.bin/rest-ez --reporter html,/absolute/path/to/js/file

linkEvents

REST-EZ emits events on launcher object and suite object, So a custom reporter should listen to these events and implement reporting.

  • Launcher
    • start Triggered once when the test run begins
    • end Triggered once when the test run ends
    • new suite Trigger {n} times at the start of each new suite
  • Suite
    • test fail Triggered {n} times (once for each), after failing spec within a suite
    • test skip Triggered {n} times (once for each), after skipped spec within a suite
    • end Triggered {n} times (once per suite), after suite finishes

linkInterface

1linkclass Reporter {

2link

3link constructor(launcher, opts = {}) {

4link

5link }

6link

7link addSuite(suite) {

8link

9link }

10link

11link getSuite(location) {

12link

13link }

14link}



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkReporters

REST-EZ has several built-in reporters, json, specs, html etc.

When you need a HTML report, you can invoke rest-ez with the --reporter option

Basic example:

1link$./node_modules/.bin/rest-ez --reporter html

Advanced example:

1link$./node_modules/.bin/rest-ez --reporter html,json --reporter-options jsonReportDir=reports,jsonReportName=json-report,htmlReportDir=reports,htmlReportName=html-report,logRequests



linkMultiple Formats

REST-EZ can generate reports in multiple formats.

When you need a HTML report and a JSON report too, you could do something like this

1link$./node_modules/.bin/rest-ez --reporter html,json

This way you can generate reports in multiple formats for the same run.



linkReporter Options

REST-EZ accepts an additonal command line option --reporter-options that you can use to customize how and where reports are generated and saved.

You must pass a comma separated list of key and value pairs to this option as k=v,k2=v2,...



linkjsonReportDir

  • Type: string optional
  • Example: test-reports
  • Default: [cwd]

Provide an existing directory path that is relative to REST-EZ node process's cwd. JSON report will be saved to this directory.

1link$./node_modules/.bin/rest-ez --reporter json --reporter-options jsonReportDir=test-reports

# Outputs to: test-reports/report.json



linkjsonReportName

  • Type: string optional
  • Example: test-report.json
  • Default: report.json

Provide a name for the JSON report file. JSON report will be saved with this name.

1link$./node_modules/.bin/rest-ez --reporter json --reporter-options jsonReportName=test-report.json

# Outputs to: test-report.json



linkhtmlReportDir

  • Type: string optional
  • Example: test-reports/
  • Default: [cwd]

Provide an existing directory path that is relative to REST-EZ node process's cwd. HTML report will be saved to this directory.

1link$./node_modules/.bin/rest-ez --reporter json --reporter-options htmlReportDir=reports,htmlReportName=test-report.json

# Outputs to: reports/test-report.json



linkhtmlReportName

  • Type: string optional
  • Example: test-report.html
  • Default: report.html

Provide a name for the HTML report file. HTML report will be saved with this name.

1link$./node_modules/.bin/rest-ez --reporter json --reporter-options htmlReportDir=html-reports,htmlReportName=latest-report.json

# Outputs to: html-reports/latest-report.json



linklogRequests

  • Type: boolean optional
  • Example: true
  • Default: false (if not provided)

Tells REST-EZ to log HTTP request & response details in reports for failed tests. Omit this if you don't want to log details.

Log all failed requests in an HTML report:

1link$./node_modules/.bin/rest-ez --reporter html --reporter-options logRequests

Log all failed requests in a JSON report:

1link$./node_modules/.bin/rest-ez --reporter json --reporter-options logRequests



linkCustom Reporters

You can write your own custom reporter.

See also: REST-EZ Built-In JSON Reporter

Reporters are JS constructors. When instantiated, a reporter receives the test launcher object along with program options.

linkRunning Custom Reporter

Using a node module by name:

1link$./node_modules/.bin/rest-ez --reporter html,custom-reporter-module-name

Using a path to a file:

1link$./node_modules/.bin/rest-ez --reporter html,/absolute/path/to/js/file

linkEvents

REST-EZ emits events on launcher object and suite object, So a custom reporter should listen to these events and implement reporting.

  • Launcher
    • start Triggered once when the test run begins
    • end Triggered once when the test run ends
    • new suite Trigger {n} times at the start of each new suite
  • Suite
    • test fail Triggered {n} times (once for each), after failing spec within a suite
    • test skip Triggered {n} times (once for each), after skipped spec within a suite
    • end Triggered {n} times (once per suite), after suite finishes

linkInterface

1linkclass Reporter {

2link

3link constructor(launcher, opts = {}) {

4link

5link }

6link

7link addSuite(suite) {

8link

9link }

10link

11link getSuite(location) {

12link

13link }

14link}



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/getting-started/rest-api.html b/docs/getting-started/basic-usage.html similarity index 53% rename from docs/getting-started/rest-api.html rename to docs/getting-started/basic-usage.html index e272746..ce43562 100644 --- a/docs/getting-started/rest-api.html +++ b/docs/getting-started/basic-usage.html @@ -1,4 +1,4 @@ -REST-EZ | REST API Spec

linkREST API Spec

Specs consistent of three basic sections:

  • Meta - Metadata about the spec
  • Configuration - Basics of where the request should point. Note that config can be dynamic using functions
  • Specs - An array of requests to run & resonse validations to perform against those requests



linkCreating a Spec

Create a new spec under the specs/ folder:

specs/star-wars-service.yml
1linkmeta:

2link name: Star Wars suite

3linkconfiguration:

4link scheme: https

5link host: swapi.dev

6link base_path: /api

7linkspecs:

8link - name: Fetch info about Luke Skywalker

9link request:

10link path: /people/1/

11link method: get

12link accept: application/json

13link response:

14link status_code: 200

15link headers:

16link - name: content-type

17link value: !!js/regexp application/json

18link json_data:

19link - path: $.name

20link value: Luke Skywalker



linkRunning the Spec

Run the spec from the terminal:

1link$./node_modules/.bin/rest-ez

Test Suite path/pattern/directory is not specified, Looking for suites in specs directory +

linkBasic Usage

Specs consistent of three basic sections:

  • Meta - Metadata about the spec
  • Configuration - Basics of where the request should point. Note that config can be dynamic using functions
  • Specs - An array of requests to run & resonse validations to perform against those requests



linkCreating a Spec

Create a new spec under the specs/ folder:

specs/star-wars-service.yml
1linkmeta:

2link name: Star Wars suite

3linkconfiguration:

4link scheme: https

5link host: swapi.dev

6link base_path: /api

7linkspecs:

8link - name: Fetch info about Luke Skywalker

9link request:

10link path: /people/1/

11link method: get

12link accept: application/json

13link response:

14link status_code: 200

15link headers:

16link - name: content-type

17link value: !!js/regexp application/json

18link json_data:

19link - path: $.name

20link value: Luke Skywalker



linkRunning the Spec

Run the spec from the terminal:

1link$./node_modules/.bin/rest-ez

Test Suite path/pattern/directory is not specified, Looking for suites in specs directory Found suites: - specs/star-wars-service.yml @@ -47,43 +47,43 @@ 0 skipped, 0 failed, 1 passing (1 tests) 0 skipped, 0 failed, 1 passing (1 suites) - Duration: 667ms

Home

Getting Startedchevron_right
Basicschevron_right

Overview + Duration: 667ms

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/getting-started/graphql.html b/docs/getting-started/graphql.html index 6edc53d..1a1c66b 100644 --- a/docs/getting-started/graphql.html +++ b/docs/getting-started/graphql.html @@ -47,43 +47,43 @@ 0 skipped, 0 failed, 1 passing (1 tests) 0 skipped, 0 failed, 1 passing (1 suites) - Duration: 667ms

Home

Getting Startedchevron_right
Basicschevron_right

Overview + Duration: 667ms

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/getting-started/installation.html b/docs/getting-started/installation.html index 98420ec..da61968 100644 --- a/docs/getting-started/installation.html +++ b/docs/getting-started/installation.html @@ -37,43 +37,43 @@ }

linkInstallation

Install with npm:

1link$npm install --save dev rest-ez


-

⚠️ Requires node >=7.10

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

⚠️ Requires node >=7.10

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/hooks/context.html b/docs/hooks/context.html index 10133d0..d1d79bb 100644 --- a/docs/hooks/context.html +++ b/docs/hooks/context.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkContext

All types of functions include appropriate context bound to this:

linkSuite

Provides the full context of the suite.

💡 Chain requests by assigning data to this.suite to utilize in subsequent specs

Available in:

  • before_all
  • after_all
  • before_each
  • after_each
  • before_test
  • after_test
get-user-addresses.yml
1link - name: get user

2link request:

3link path: /user

4link method: get

5link before_test:

6link run_type: module

7link module:

8link function: !!js/function >

9link function () {

10link this.suite.user = JSON.parse(this.response.body);

11link }

12link - name: get addresses

13link request:

14link path: /users/{userId}/addresses

15link method: get

16link after_test:

17link run_type: module

18link module:

19link function: !!js/function >

20link function () {

21link const { id } = this.suite.user;

22link this.suite.path_params = { userId: id };

23link }



linkTest

Provides the full context of the test (spec). Modify its properties on a before_* hook to change the spec request.

💡 Chain requests by utilizing data previously saved to this.suite to modify the spec.

Available in:

  • before_each
  • after_each
  • before_test
  • after_test
get-user-addresses.yml
1link - name: get user

2link request:

3link path: /user

4link method: get

5link before_test:

6link run_type: module

7link module:

8link function: !!js/function >

9link function () {

10link this.suite.user = JSON.parse(this.response.body);

11link }

12link - name: get addresses

13link request:

14link path: /users/{userId}/addresses

15link method: get

16link after_test:

17link run_type: module

18link module:

19link function: !!js/function >

20link function () {

21link const { id } = this.suite.user;

22link this.suite.path_params = { userId: id };

23link }



linkResponse

Provides full information about the response of this spec.

Available in:

  • after_each
  • after_test
get-user-addresses.yml
1link - name: get user

2link request:

3link path: /user

4link method: get

5link before_test:

6link run_type: module

7link module:

8link function: !!js/function >

9link function () {

10link this.suite.user = JSON.parse(this.response.body);

11link }



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkContext

All types of functions include appropriate context bound to this:

linkSuite

Provides the full context of the suite.

💡 Chain requests by assigning data to this.suite to utilize in subsequent specs

Available in:

  • before_all
  • after_all
  • before_each
  • after_each
  • before_test
  • after_test
get-user-addresses.yml
1link - name: get user

2link request:

3link path: /user

4link method: get

5link before_test:

6link run_type: module

7link module:

8link function: !!js/function >

9link function () {

10link this.suite.user = JSON.parse(this.response.body);

11link }

12link - name: get addresses

13link request:

14link path: /users/{userId}/addresses

15link method: get

16link after_test:

17link run_type: module

18link module:

19link function: !!js/function >

20link function () {

21link const { id } = this.suite.user;

22link this.suite.path_params = { userId: id };

23link }



linkTest

Provides the full context of the test (spec). Modify its properties on a before_* hook to change the spec request.

💡 Chain requests by utilizing data previously saved to this.suite to modify the spec.

Available in:

  • before_each
  • after_each
  • before_test
  • after_test
get-user-addresses.yml
1link - name: get user

2link request:

3link path: /user

4link method: get

5link before_test:

6link run_type: module

7link module:

8link function: !!js/function >

9link function () {

10link this.suite.user = JSON.parse(this.response.body);

11link }

12link - name: get addresses

13link request:

14link path: /users/{userId}/addresses

15link method: get

16link after_test:

17link run_type: module

18link module:

19link function: !!js/function >

20link function () {

21link const { id } = this.suite.user;

22link this.suite.path_params = { userId: id };

23link }



linkResponse

Provides full information about the response of this spec.

Available in:

  • after_each
  • after_test
get-user-addresses.yml
1link - name: get user

2link request:

3link path: /user

4link method: get

5link before_test:

6link run_type: module

7link module:

8link function: !!js/function >

9link function () {

10link this.suite.user = JSON.parse(this.response.body);

11link }



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/hooks/list.html b/docs/hooks/list.html index 9e9cf67..a91c321 100644 --- a/docs/hooks/list.html +++ b/docs/hooks/list.html @@ -45,43 +45,43 @@
1linkmeta:

2link name: Star Wars suite

3linkconfiguration:

4link scheme: https

5link host: swapi.dev

6link base_path: /api

7link

8linkspecs:

9link - name: Get some user

10link request:

11link path: /people/1/ # <--- runs random {n} times with random ID between 1 to 100

12link method: get

13link after_test:

14link run_type: inline

15link inline:

16link function: !!js/function >

17link function () {

18link this.suite.person = JSON.parse(this.response.body);

19link }

20link response:

21link status_code: 200


-

⚠️ NOTE: as above, specifying this.test for headers, cookies, path_prams, & query_params uses a plain key/value set as an object, and DOES NOT use the same [{ name: 'name', value: 'value'}] format used when specifying in yaml. This will be fixed in future versions for consistency.



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

⚠️ NOTE: as above, specifying this.test for headers, cookies, path_prams, & query_params uses a plain key/value set as an object, and DOES NOT use the same [{ name: 'name', value: 'value'}] format used when specifying in yaml. This will be fixed in future versions for consistency.



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/hooks/overview.html b/docs/hooks/overview.html index 0c9f7cd..166f1df 100644 --- a/docs/hooks/overview.html +++ b/docs/hooks/overview.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkHooks & JS

linkBasics

Write your own custom JS (including external JS files) to process & make assertions of any sort.

linkTypes

REST-EZ supports three ways of writing custom JS:

linkList of Hooks

The following List of Hooks are supported:

linkContext

JS functions have access to different hook context via this keyword.



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkHooks & JS

linkBasics

Write your own custom JS (including external JS files) to process & make assertions of any sort.

linkTypes

REST-EZ supports three ways of writing custom JS:

linkList of Hooks

The following List of Hooks are supported:

linkContext

JS functions have access to different hook context via this keyword.



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/hooks/types.html b/docs/hooks/types.html index 985b1d1..bea8de1 100644 --- a/docs/hooks/types.html +++ b/docs/hooks/types.html @@ -39,45 +39,45 @@

Use the arguments property to pass an array of arguments:

1link# basic function (synchronous)

2linkrun_type: inline

3linkinline:

4link arguments:

5link - Kiran Mandadi

6link function: !!js/function >

7link function (name) {

8link console.log(`Hello, ${name}.`);

9link }

10link



linkJS Async Functions

Basic usage:

1link# async function

2linkrun_type: inline

3linkinline:

4link function: !js/asyncFunction >

5link async function () {

6link // return new Promise((resolve, reject) => { ... });

7link // -- or --

8link // return await doSomething();

9link }


-

Use the arguments property to pass an array of arguments:

1link# async function

2linkrun_type: inline

3linkinline:

4link arguments:

5link - name: Matthew

6link dob: 1984-03-02

7link function: !js/asyncFunction >

8link async function (options) {

9link // return await doSomething(options.name, options.dob);

10link // -- or --

11link // return new Promise((resolve, reject) => { ... });

12link }



⚠️ NOTE: using require or import inside inline function is not yet supported. Use the JS modules approach below:



linkJS From External Files

You can run code from any external file:

some-suite.yml
1linkrun_type: module

2linkmodule:

3link module_path: 'path/to/a/file.js'

4link function_name: nameOfSomeFunction

path/to/a/file.js
1linkmodule.exports = {

2link someFunction: function () {

3link // do something

4link }

5link};


+

Use the arguments property to pass an array of arguments:

1link# async function

2linkrun_type: inline

3linkinline:

4link arguments:

5link - name: Matthew

6link dob: 1984-03-02

7link function: !js/asyncFunction >

8link async function (options) {

9link // return await doSomething(options.name, options.dob);

10link // -- or --

11link // return new Promise((resolve, reject) => { ... });

12link }



⚠️ NOTE: using require or import inside inline function is not yet supported. Use the JS modules approach below:



linkJS From External Files

You can run code from any external file:

some-suite.yml
1linkrun_type: module

2linkmodule:

3link module_path: 'path/to/a/file.js'

4link function_name: nameOfSomeFunction

path/to/a/file.js
1linkmodule.exports = {

2link someFunction: function () {

3link // do something

4link }

5link};


-

Use the arguments property to pass an array of arguments:

some-suite.yml
1linkrun_type: module

2linkmodule:

3link arguments:

4link - Argument one is a string.

5link - { name: 'Person', age: 72 }

6link - [ 'argument', 3, 'is', an', 'array' ]

7link module_path: 'path/to/a/file.js'

8link function_name: nameOfSomeFunction

path/to/a/file.js
1linkmodule.exports = {

2link someFunction: function (arg1, arg2) {

3link // do something

4link }

5link};



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

Use the arguments property to pass an array of arguments:

some-suite.yml
1linkrun_type: module

2linkmodule:

3link arguments:

4link - Argument one is a string.

5link - { name: 'Person', age: 72 }

6link - [ 'argument', 3, 'is', an', 'array' ]

7link module_path: 'path/to/a/file.js'

8link function_name: nameOfSomeFunction

path/to/a/file.js
1linkmodule.exports = {

2link someFunction: function (arg1, arg2) {

3link // do something

4link }

5link};



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/md/_toc.md b/docs/md/_toc.md index cb92490..65ccf5f 100644 --- a/docs/md/_toc.md +++ b/docs/md/_toc.md @@ -3,7 +3,7 @@ > :Collapse label=Getting Started > > [Installation](/docs/getting-started/installation) -> [REST API](/docs/getting-started/rest-api) +> [Basic Usage](/docs/getting-started/basic-usage) > [GraphQL](/docs/getting-started/graphql) > :Collapse label=Basics diff --git a/docs/md/docs/getting-started/rest-api.md b/docs/md/docs/getting-started/basic-usage.md similarity index 99% rename from docs/md/docs/getting-started/rest-api.md rename to docs/md/docs/getting-started/basic-usage.md index 52c6611..b4a19af 100644 --- a/docs/md/docs/getting-started/rest-api.md +++ b/docs/md/docs/getting-started/basic-usage.md @@ -1,4 +1,4 @@ -# REST API Spec +# Basic Usage Specs consistent of three basic sections: diff --git a/docs/request/additional-options.html b/docs/request/additional-options.html index 49402cf..261d0b2 100644 --- a/docs/request/additional-options.html +++ b/docs/request/additional-options.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkRequest Additional Options

linkfollowRedirect

  • Type: boolean optional
  • Values: true, false
  • Default: true

If enabled, follow HTTP 3xx responses as redirects.

1link - request:

2link path: /home

3link method: get

4link additional_options:

5link followRedirect: false

6link response:

7link status_code: 200



linkfollowAllRedirects

  • Type: boolean optional
  • Values: true, false
  • Default: false

If enabled, follow non-GET HTTP 3xx responses as redirects.

1link - request:

2link path: /home

3link method: get

4link additional_options:

5link followRedirect: true

6link followAllRedirects: true

7link response:

8link status_code: 200



linkfollowOriginalHttpMethod

  • Type: boolean optional
  • Values: true, false
  • Default: false

If enabled, redirect to the original HTTP method.

If disabled (by default), redirects to the original HTTP method.

1link - request:

2link path: /home

3link method: get

4link additional_options:

5link followRedirect: true

6link followOriginalHttpMethod: true

7link response:

8link status_code: 200



linkencoding

  • Type: string optional
  • Examples: utf8, null
  • Default: utf8

Encoding to be used on setEncoding of response data.

If null, the body is returned as a raw Buffer.

If specified, passed as encoding parameter of Buffer.toString().

⚠️ Note: if expecting binary data, use encoding: null to get the raw Buffer

1link - request:

2link path: /files/some-file.png

3link method: get

4link additional_options:

5link encoding: null

6link response:

7link status_code: 200



linkgzip

  • Type: boolean optional
  • Values: true, false

If enabled, adds an Accept-Encoding header to request compressed content encodings from the server (if not already present).

Also decodes supported content encodings in the response.

1link - request:

2link path: /home

3link method: get

4link additional_options:

5link gzip: true

6link response:

7link status_code: 200



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkRequest Additional Options

linkfollowRedirect

  • Type: boolean optional
  • Values: true, false
  • Default: true

If enabled, follow HTTP 3xx responses as redirects.

1link - request:

2link path: /home

3link method: get

4link additional_options:

5link followRedirect: false

6link response:

7link status_code: 200



linkfollowAllRedirects

  • Type: boolean optional
  • Values: true, false
  • Default: false

If enabled, follow non-GET HTTP 3xx responses as redirects.

1link - request:

2link path: /home

3link method: get

4link additional_options:

5link followRedirect: true

6link followAllRedirects: true

7link response:

8link status_code: 200



linkfollowOriginalHttpMethod

  • Type: boolean optional
  • Values: true, false
  • Default: false

If enabled, redirect to the original HTTP method.

If disabled (by default), redirects to the original HTTP method.

1link - request:

2link path: /home

3link method: get

4link additional_options:

5link followRedirect: true

6link followOriginalHttpMethod: true

7link response:

8link status_code: 200



linkencoding

  • Type: string optional
  • Examples: utf8, null
  • Default: utf8

Encoding to be used on setEncoding of response data.

If null, the body is returned as a raw Buffer.

If specified, passed as encoding parameter of Buffer.toString().

⚠️ Note: if expecting binary data, use encoding: null to get the raw Buffer

1link - request:

2link path: /files/some-file.png

3link method: get

4link additional_options:

5link encoding: null

6link response:

7link status_code: 200



linkgzip

  • Type: boolean optional
  • Values: true, false

If enabled, adds an Accept-Encoding header to request compressed content encodings from the server (if not already present).

Also decodes supported content encodings in the response.

1link - request:

2link path: /home

3link method: get

4link additional_options:

5link gzip: true

6link response:

7link status_code: 200



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/request/cookies.html b/docs/request/cookies.html index be549b5..2ba9668 100644 --- a/docs/request/cookies.html +++ b/docs/request/cookies.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkRequest Cookies

Optionally specify a list of cookies to be sent with the request. These will be sent as distinct Cookie headers (as per the HTTP spec).

  • Type: array optional

linkBasic Example

1linkconfiguration:

2link host: api.mycompany.com

3link scheme: https

4link base_path: /api

5linkspecs:

6link - request:

7link method: get

8link path: /account

9link headers:

10link - name: Accept

11link value: application/json

12link cookies:

13link - name: XSRF-Token

14link value: 399do284kds32odh28

15link response:

16link status_code: 200

See also: Example: Suite Using Cookies



linkDynamically Set Cookies

Dynamic cookies can be added by setting cookies as an object to the this.test context:

  • Type: object optional
1linkconfiguration:

2link scheme: http

3link host: 127.0.0.1

4link port: 3027

5linkspecs:

6link - before_test:

7link run_type: inline

8link inline:

9link function: !!js/function >

10link function() {

11link this.test.cookies = {cookie1: 'cookie1-value'}

12link }

13link request:

14link path: /echoCookies

15link method: get

16link response:

17link status_code: 200

18link json_data:

19link - path: $.cookie1

20link value: cookie1-value

See also: Example: Suite Using Cookies



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkRequest Cookies

Optionally specify a list of cookies to be sent with the request. These will be sent as distinct Cookie headers (as per the HTTP spec).

  • Type: array optional

linkBasic Example

1linkconfiguration:

2link host: api.mycompany.com

3link scheme: https

4link base_path: /api

5linkspecs:

6link - request:

7link method: get

8link path: /account

9link headers:

10link - name: Accept

11link value: application/json

12link cookies:

13link - name: XSRF-Token

14link value: 399do284kds32odh28

15link response:

16link status_code: 200

See also: Example: Suite Using Cookies



linkDynamically Set Cookies

Dynamic cookies can be added by setting cookies as an object to the this.test context:

  • Type: object optional
1linkconfiguration:

2link scheme: http

3link host: 127.0.0.1

4link port: 3027

5linkspecs:

6link - before_test:

7link run_type: inline

8link inline:

9link function: !!js/function >

10link function() {

11link this.test.cookies = {cookie1: 'cookie1-value'}

12link }

13link request:

14link path: /echoCookies

15link method: get

16link response:

17link status_code: 200

18link json_data:

19link - path: $.cookie1

20link value: cookie1-value

See also: Example: Suite Using Cookies



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/request/file-uploads.html b/docs/request/file-uploads.html index 32b44cd..8bc5ca8 100644 --- a/docs/request/file-uploads.html +++ b/docs/request/file-uploads.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkFile Uploads

File uploads are supported using the form_data property.

⚠️ Note: when using the form_data property with URL encoded data, you MUST ALSO send header content-type: multipart/form-data

1link - name: post multipart form data - single file & two text fields

2link request:

3link path: /register

4link method: post

5link headers:

6link - name: content-type

7link value: multipart/form-data

8link payload:

9link form_data:

10link - name: dob

11link type: text

12link content: '1980-01-04'

13link - name: email

14link type: text

15link content: person@company.com

16link - name: photo-id-file

17link type: file

18link content: static/assets/example-id-card.png

19link response:

20link status_code: 200

⚠️ Note: the file path should be relative to Node process's current working directory.

💡 To use a path relative to suite's path use the locate_files_relative option in the suite meta section

See also:



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkFile Uploads

File uploads are supported using the form_data property.

⚠️ Note: when using the form_data property with URL encoded data, you MUST ALSO send header content-type: multipart/form-data

1link - name: post multipart form data - single file & two text fields

2link request:

3link path: /register

4link method: post

5link headers:

6link - name: content-type

7link value: multipart/form-data

8link payload:

9link form_data:

10link - name: dob

11link type: text

12link content: '1980-01-04'

13link - name: email

14link type: text

15link content: person@company.com

16link - name: photo-id-file

17link type: file

18link content: static/assets/example-id-card.png

19link response:

20link status_code: 200

⚠️ Note: the file path should be relative to Node process's current working directory.

💡 To use a path relative to suite's path use the locate_files_relative option in the suite meta section

See also:



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/request/headers.html b/docs/request/headers.html index 55fb3f6..078f114 100644 --- a/docs/request/headers.html +++ b/docs/request/headers.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkRequest Headers

Optionally specify a list of headers to be added to the request.

  • Type: array optional



linkBasic Example

1linkconfiguration:

2link host: swapi.dev

3link scheme: https

4link base_path: /api

5linkspecs:

6link - request:

7link method: get

8link path: /films/1/

9link headers:

10link - name: Accept

11link value: application/json

12link - name: X-CustomHeader

13link value: some-value

14link response:

15link status_code: 200

See also: Example: Suite Using Headers



linkDynamically Set Headers

Dynamic headers can be added by setting headers as an object to the this.test context:

  • Type: object optional
1linkconfiguration:

2link scheme: http

3link host: 127.0.0.1

4link port: 3027

5linkspecs:

6link - before_test:

7link run_type: inline

8link inline:

9link function: !!js/function >

10link function() {

11link this.test.headers = { header2: 'header2-value' };

12link }

13link request:

14link path: /echoHeaders

15link method: get

16link headers:

17link - name: header1

18link value: header1-value

19link response:

20link json_data:

21link - path: "$.header2"

22link value: "header2-value"

23link - path: "$.header1"

24link value: "header1-value"

See also: Overview of Hooks



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkRequest Headers

Optionally specify a list of headers to be added to the request.

  • Type: array optional



linkBasic Example

1linkconfiguration:

2link host: swapi.dev

3link scheme: https

4link base_path: /api

5linkspecs:

6link - request:

7link method: get

8link path: /films/1/

9link headers:

10link - name: Accept

11link value: application/json

12link - name: X-CustomHeader

13link value: some-value

14link response:

15link status_code: 200

See also: Example: Suite Using Headers



linkDynamically Set Headers

Dynamic headers can be added by setting headers as an object to the this.test context:

  • Type: object optional
1linkconfiguration:

2link scheme: http

3link host: 127.0.0.1

4link port: 3027

5linkspecs:

6link - before_test:

7link run_type: inline

8link inline:

9link function: !!js/function >

10link function() {

11link this.test.headers = { header2: 'header2-value' };

12link }

13link request:

14link path: /echoHeaders

15link method: get

16link headers:

17link - name: header1

18link value: header1-value

19link response:

20link json_data:

21link - path: "$.header2"

22link value: "header2-value"

23link - path: "$.header1"

24link value: "header1-value"

See also: Overview of Hooks



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/request/methods.html b/docs/request/methods.html index 99e7d14..0c0e346 100644 --- a/docs/request/methods.html +++ b/docs/request/methods.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkRequest Methods

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkRequest Methods

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/request/path-parameters.html b/docs/request/path-parameters.html index e6fa2b8..e592368 100644 --- a/docs/request/path-parameters.html +++ b/docs/request/path-parameters.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkRequest Path Parameters

Modify the URL by specifying parameters to plug into the path, either hard-coded or dynamically.

  • Type: array required

linkBasic Example

1linkconfiguration:

2link host: api.mycompany.com

3link scheme: https

4link base_path: /api

5linkspecs:

6link - request:

7link path: /users/{userId}/addresses/{addressId}

8link method: get

9link path_params:

10link - name: userId

11link value: 4

12link - name: addressId

13link value: 1

14link response:

15link status_code: 200

16link# GET https://api.mycompany.com/users/4/addresses/1

See also: Example: Suite Using Query Params



linkDynamically Set Query Parameters

Dynamic query params can be added by setting path_params as an object to the this.test context:

1linkconfiguration:

2link host: api.mycompany.com

3link scheme: https

4link base_path: /api

5linkspecs:

6link - before_test:

7link run_type: inline

8link inline:

9link function: !!js/function >

10link function () {

11link this.test.path_params = {

12link userId: 4,

13link addressId: 1

14link };

15link }

16link request:

17link path: /users/{userId}/addresses/{addressId}

18link method: get

19link response:

20link status_code: 200

21link# GET https://api.mycompany.com/users/4/addresses/1

See also: Overview of Hooks



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkRequest Path Parameters

Modify the URL by specifying parameters to plug into the path, either hard-coded or dynamically.

  • Type: array required

linkBasic Example

1linkconfiguration:

2link host: api.mycompany.com

3link scheme: https

4link base_path: /api

5linkspecs:

6link - request:

7link path: /users/{userId}/addresses/{addressId}

8link method: get

9link path_params:

10link - name: userId

11link value: 4

12link - name: addressId

13link value: 1

14link response:

15link status_code: 200

16link# GET https://api.mycompany.com/users/4/addresses/1

See also: Example: Suite Using Query Params



linkDynamically Set Query Parameters

Dynamic query params can be added by setting path_params as an object to the this.test context:

1linkconfiguration:

2link host: api.mycompany.com

3link scheme: https

4link base_path: /api

5linkspecs:

6link - before_test:

7link run_type: inline

8link inline:

9link function: !!js/function >

10link function () {

11link this.test.path_params = {

12link userId: 4,

13link addressId: 1

14link };

15link }

16link request:

17link path: /users/{userId}/addresses/{addressId}

18link method: get

19link response:

20link status_code: 200

21link# GET https://api.mycompany.com/users/4/addresses/1

See also: Overview of Hooks



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/request/payload-body/binary-data.html b/docs/request/payload-body/binary-data.html index e644580..eb9c29a 100644 --- a/docs/request/payload-body/binary-data.html +++ b/docs/request/payload-body/binary-data.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkBinary Data

Send binary data by specifying a file path.

⚠️ Note: when using type: binary you MUST send an appropriate mime type header, such as content-type: image/png, content-type: image/jpeg, etc.

1link - name: post binary data (file) as body

2link request:

3link path: /profile-photo

4link method: post

5link headers:

6link - name: content-type

7link value: image/png

8link payload:

9link body:

10link type: binary

11link content: static/assets/image.png # <-- the image path

12link response:

13link status_code: 200

⚠️ Note: the image path should be relative to Node process's current working directory.

💡 To use a path relative to suite's path use the locate_files_relative option in the suite meta section

See also: Example: Binary Data

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkBinary Data

Send binary data by specifying a file path.

⚠️ Note: when using type: binary you MUST send an appropriate mime type header, such as content-type: image/png, content-type: image/jpeg, etc.

1link - name: post binary data (file) as body

2link request:

3link path: /profile-photo

4link method: post

5link headers:

6link - name: content-type

7link value: image/png

8link payload:

9link body:

10link type: binary

11link content: static/assets/image.png # <-- the image path

12link response:

13link status_code: 200

⚠️ Note: the image path should be relative to Node process's current working directory.

💡 To use a path relative to suite's path use the locate_files_relative option in the suite meta section

See also: Example: Binary Data

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/request/payload-body/json-body.html b/docs/request/payload-body/json-body.html index 2f17de8..5bb8e84 100644 --- a/docs/request/payload-body/json-body.html +++ b/docs/request/payload-body/json-body.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkJSON Body

Send JSON by specifying type: json and the content property.

⚠️ Note: when using type: json you MUST send the header content-type: application/json

1link - name: create a new user

2link request:

3link path: /users

4link method: post

5link headers:

6link - name: content-type

7link value: application/json

8link payload:

9link body:

10link type: json

11link content:

12link firstName: john

13link lastName: doe

14link response:

15link status_code: 201

See also:



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkJSON Body

Send JSON by specifying type: json and the content property.

⚠️ Note: when using type: json you MUST send the header content-type: application/json

1link - name: create a new user

2link request:

3link path: /users

4link method: post

5link headers:

6link - name: content-type

7link value: application/json

8link payload:

9link body:

10link type: json

11link content:

12link firstName: john

13link lastName: doe

14link response:

15link status_code: 201

See also:



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/request/payload-body/multi-part-form-data.html b/docs/request/payload-body/multi-part-form-data.html index c0f958f..4e2c22d 100644 --- a/docs/request/payload-body/multi-part-form-data.html +++ b/docs/request/payload-body/multi-part-form-data.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkMulti-Part Form Data

To send multi-part form data, use the form_data property. This is also how to send file uploads

⚠️ Note: when using the form_data property with URL encoded data, you MUST ALSO send header content-type: multipart/form-data

1link - name: post multipart form data - single file and field

2link request:

3link path: /register

4link method: post

5link headers:

6link - name: content-type

7link value: multipart/form-data

8link payload:

9link form_data:

10link - name: dob

11link type: text

12link content: '1980-01-04'

13link - name: email

14link type: text

15link content: person@company.com

16link - name: photo-id-file

17link type: file

18link content: static/assets/example-id-card.png

19link response:

20link status_code: 200

See also:

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkMulti-Part Form Data

To send multi-part form data, use the form_data property. This is also how to send file uploads

⚠️ Note: when using the form_data property with URL encoded data, you MUST ALSO send header content-type: multipart/form-data

1link - name: post multipart form data - single file and field

2link request:

3link path: /register

4link method: post

5link headers:

6link - name: content-type

7link value: multipart/form-data

8link payload:

9link form_data:

10link - name: dob

11link type: text

12link content: '1980-01-04'

13link - name: email

14link type: text

15link content: person@company.com

16link - name: photo-id-file

17link type: file

18link content: static/assets/example-id-card.png

19link response:

20link status_code: 200

See also:

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/request/payload-body/url-encoded-form-data.html b/docs/request/payload-body/url-encoded-form-data.html index 696ecf9..deb3630 100644 --- a/docs/request/payload-body/url-encoded-form-data.html +++ b/docs/request/payload-body/url-encoded-form-data.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkURL Encoded Form Data

URL encoded form data (old school style) can be submitted using the form property.

⚠️ Note: when using the form property with URL encoded data, you MUST ALSO send header content-type: application/x-www-form-urlencoded

1link - name: Authenticate a user

2link request:

3link path: /authenticate

4link method: post

5link headers:

6link - name: content-type

7link value: application/x-www-form-urlencoded

8link payload:

9link form:

10link userName: john.doe

11link password: john.doe.password

12link response:

13link status_code: 200

See also: Example: URL Encoded Form Post

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkURL Encoded Form Data

URL encoded form data (old school style) can be submitted using the form property.

⚠️ Note: when using the form property with URL encoded data, you MUST ALSO send header content-type: application/x-www-form-urlencoded

1link - name: Authenticate a user

2link request:

3link path: /authenticate

4link method: post

5link headers:

6link - name: content-type

7link value: application/x-www-form-urlencoded

8link payload:

9link form:

10link userName: john.doe

11link password: john.doe.password

12link response:

13link status_code: 200

See also: Example: URL Encoded Form Post

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/request/query-parameters.html b/docs/request/query-parameters.html index cbde894..da3aa51 100644 --- a/docs/request/query-parameters.html +++ b/docs/request/query-parameters.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkRequest Query Parameters

Update (or override) request query params.

  • Type: array required

linkBasic Example

1linkconfiguration:

2link host: api.mycompany.com

3link scheme: https

4link base_path: /api

5linkspecs:

6link - request:

7link path: /users

8link method: get

9link query_params:

10link - name: firstName

11link value: Matthew

12link response:

13link status_code: 200

14link# GET https://api.mycompany.com/users?firstName=Matthew

See also: Example: Suite Using Query Params



linkDynamically Set Query Parameters

Dynamic query params can be added by setting query_params as an object to the this.test context:

1linkconfiguration:

2link host: api.mycompany.com

3link scheme: https

4link base_path: /api

5linkspecs:

6link - before_test:

7link run_type: inline

8link inline:

9link function: !!js/function >

10link function () {

11link this.test.query_params = {

12link firstName: 'Matthew',

13link };

14link }

15link request:

16link path: /users

17link method: get

18link response:

19link status_code: 200

20link# GET https://api.mycompany.com/users?firstName=Matthew

See also: Overview of Hooks



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkRequest Query Parameters

Update (or override) request query params.

  • Type: array required

linkBasic Example

1linkconfiguration:

2link host: api.mycompany.com

3link scheme: https

4link base_path: /api

5linkspecs:

6link - request:

7link path: /users

8link method: get

9link query_params:

10link - name: firstName

11link value: Matthew

12link response:

13link status_code: 200

14link# GET https://api.mycompany.com/users?firstName=Matthew

See also: Example: Suite Using Query Params



linkDynamically Set Query Parameters

Dynamic query params can be added by setting query_params as an object to the this.test context:

1linkconfiguration:

2link host: api.mycompany.com

3link scheme: https

4link base_path: /api

5linkspecs:

6link - before_test:

7link run_type: inline

8link inline:

9link function: !!js/function >

10link function () {

11link this.test.query_params = {

12link firstName: 'Matthew',

13link };

14link }

15link request:

16link path: /users

17link method: get

18link response:

19link status_code: 200

20link# GET https://api.mycompany.com/users?firstName=Matthew

See also: Overview of Hooks



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/request/request-basics.html b/docs/request/request-basics.html index b64bc40..a0e81ff 100644 --- a/docs/request/request-basics.html +++ b/docs/request/request-basics.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkRequest Basics

Each spec must define a request that defines the HTTP request to be made

Required properties:

Optional properties:

ℹ️ NOTE: headers, cookies, path_params, query_params all use an array of objects with name and value

1link- name: some-name-1

2link value: Some Value

3link- name: other-name-2

4link value: Other Value

linkmethod

  • Type: string required
  • Values: get, post, put, patch, delete, head, options

linkpath:

  • Type: string required
1linkconfiguration:

2link host: swapi.dev

3link scheme: https

4link base_path: /api

5linkspecs:

6link - request:

7link method: get

8link path: /films/1/

9link response:

10link status_code: 200

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkRequest Basics

Each spec must define a request that defines the HTTP request to be made

Required properties:

Optional properties:

ℹ️ NOTE: headers, cookies, path_params, query_params all use an array of objects with name and value

1link- name: some-name-1

2link value: Some Value

3link- name: other-name-2

4link value: Other Value

linkmethod

  • Type: string required
  • Values: get, post, put, patch, delete, head, options

linkpath:

  • Type: string required
1linkconfiguration:

2link host: swapi.dev

3link scheme: https

4link base_path: /api

5linkspecs:

6link - request:

7link method: get

8link path: /films/1/

9link response:

10link status_code: 200

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/response-validation/body/json-schema-file.html b/docs/response-validation/body/json-schema-file.html index 781e8ac..d41e9f7 100644 --- a/docs/response-validation/body/json-schema-file.html +++ b/docs/response-validation/body/json-schema-file.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkJSON Schema File

Validate the response body using an external JSON Schema file.

Both JSON and YAML files are supported.

NOTE: All $refs are dynamically de-referenced automatically, both locally and remotely.

linkRoot Schema

Use an external file from the root-level schema.

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link json_schema:

7link type: file

8link $ref: static/schemas/users.json # path to the expected schema file



linkSub-Property

Validate against some sub-property within a schema file by using a JSON Pointer in the $ref

💡 HINT: this is very useful if you already have an Open API / Swagger spec since

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link json_schema:

7link type: file

8link # uses property $.components.schemas.users

9link # within file 'static/schemas/open-api.json'

10link $ref: 'static/schemas/open-api.yml#/components/schemas/users'

💡 NOTE: paths containing a forward slash can be URL-encoded as %2F



See also:



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkJSON Schema File

Validate the response body using an external JSON Schema file.

Both JSON and YAML files are supported.

NOTE: All $refs are dynamically de-referenced automatically, both locally and remotely.

linkRoot Schema

Use an external file from the root-level schema.

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link json_schema:

7link type: file

8link $ref: static/schemas/users.json # path to the expected schema file



linkSub-Property

Validate against some sub-property within a schema file by using a JSON Pointer in the $ref

💡 HINT: this is very useful if you already have an Open API / Swagger spec since

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link json_schema:

7link type: file

8link # uses property $.components.schemas.users

9link # within file 'static/schemas/open-api.json'

10link $ref: 'static/schemas/open-api.yml#/components/schemas/users'

💡 NOTE: paths containing a forward slash can be URL-encoded as %2F



See also:



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/response-validation/body/json-schema-inline.html b/docs/response-validation/body/json-schema-inline.html index 0dbbcd5..5b4d1bf 100644 --- a/docs/response-validation/body/json-schema-inline.html +++ b/docs/response-validation/body/json-schema-inline.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkJSON Schema Inline Validation

You can write inline schemas to validate the response body.

1link - name: update user

2link request:

3link path: /user

4link method: put

5link response:

6link json_schema:

7link type: inline

8link $ref: >

9link {

10link "type": "object",

11link "properties": {

12link "dob": {

13link "type": "string",

14link "format": "date-time"

15link }

16link },

17link "required": "dob"

18link }

See also:



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkJSON Schema Inline Validation

You can write inline schemas to validate the response body.

1link - name: update user

2link request:

3link path: /user

4link method: put

5link response:

6link json_schema:

7link type: inline

8link $ref: >

9link {

10link "type": "object",

11link "properties": {

12link "dob": {

13link "type": "string",

14link "format": "date-time"

15link }

16link },

17link "required": "dob"

18link }

See also:



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/response-validation/body/overview.html b/docs/response-validation/body/overview.html index 5b34736..23fa756 100644 --- a/docs/response-validation/body/overview.html +++ b/docs/response-validation/body/overview.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkResponse Body Validation Overview



linkExact Value

Check the response body exactly matches some value

1link# TODO



linkJSON Path

linkExact Value

Check the property at the specified path matches an exact value:

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link json_data:

7link - path: $.[0].firstName

8link value: john



linkRegular Expression

Check for a regex match at the specified path:

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link json_data:

7link - path: $.[0].zipcode

8link value: !!js/regex /^\d{5}$/

See also: Example: Validation of JSON Data



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkResponse Body Validation Overview



linkExact Value

Check the response body exactly matches some value

1link# TODO



linkJSON Path

linkExact Value

Check the property at the specified path matches an exact value:

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link json_data:

7link - path: $.[0].firstName

8link value: john



linkRegular Expression

Check for a regex match at the specified path:

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link json_data:

7link - path: $.[0].zipcode

8link value: !!js/regex /^\d{5}$/

See also: Example: Validation of JSON Data



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/response-validation/body/swagger-open-api.html b/docs/response-validation/body/swagger-open-api.html index c64a28c..cd95a26 100644 --- a/docs/response-validation/body/swagger-open-api.html +++ b/docs/response-validation/body/swagger-open-api.html @@ -35,45 +35,45 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkSwagger & Open API

If you already have an Open API / swagger defined, you can use it to validate actual responses.

Both JSON and YAML files are supported.

⚠️ NOTE: All $ref are dynamically de-referenced automatically, those both local AND remote.



specs/example-spec.yml
1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link json_schema:

7link type: file

8link # note the use of %2F to escape the "application/json" part of the path

9link $ref: 'docs/paths/register.yml#/post/responses/200/content/application%2Fjson/schema'

docs/paths/register.yml
1linkpost:

2link responses:

3link '200':

4link content:

5link application/json:

6link schema:

7link type: object

8link properties:

9link dob:

10link type: string

11link format: date-time

12link required: [ dob ]


+

linkSwagger & Open API

If you already have an Open API / swagger defined, you can use it to validate actual responses.

Both JSON and YAML files are supported.

⚠️ NOTE: All $ref are dynamically de-referenced automatically, those both local AND remote.



specs/example-spec.yml
1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link json_schema:

7link type: file

8link # note the use of %2F to escape the "application/json" part of the path

9link $ref: 'docs/paths/register.yml#/post/responses/200/content/application%2Fjson/schema'

docs/paths/register.yml
1linkpost:

2link responses:

3link '200':

4link content:

5link application/json:

6link schema:

7link type: object

8link properties:

9link dob:

10link type: string

11link format: date-time

12link required: [ dob ]


-

💡 NOTE: paths containing a forward slash can be URL-encoded as %2F



See also:



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

💡 NOTE: paths containing a forward slash can be URL-encoded as %2F



See also:



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/response-validation/cookies.html b/docs/response-validation/cookies.html index 79a018e..2e2172d 100644 --- a/docs/response-validation/cookies.html +++ b/docs/response-validation/cookies.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/response-validation/headers.html b/docs/response-validation/headers.html index a3cb6a5..d845ca6 100644 --- a/docs/response-validation/headers.html +++ b/docs/response-validation/headers.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/response-validation/overview.html b/docs/response-validation/overview.html index 13ca535..80afd47 100644 --- a/docs/response-validation/overview.html +++ b/docs/response-validation/overview.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

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:

  • response.body
  • response.statusCode
  • response.statusMessage
  • response.headers
  • response.body
  • response.duration



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



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

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:

  • response.body
  • response.statusCode
  • response.statusMessage
  • response.headers
  • response.body
  • response.duration



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



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/response-validation/status-code.html b/docs/response-validation/status-code.html index b0bcab3..f97aa29 100644 --- a/docs/response-validation/status-code.html +++ b/docs/response-validation/status-code.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkStatus Code Validation

  • Type: integer optional

Ensure the HTTP status code matches what is expected.

Test will fail when actual response's status code does not match with specified value.

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link status_code: 400



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkStatus Code Validation

  • Type: integer optional

Ensure the HTTP status code matches what is expected.

Test will fail when actual response's status code does not match with specified value.

1link - name: get users

2link request:

3link path: /users

4link method: get

5link response:

6link status_code: 400



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/reusing-specs/intersuite-spec-deps.html b/docs/reusing-specs/intersuite-spec-deps.html index 5b01798..81e22f7 100644 --- a/docs/reusing-specs/intersuite-spec-deps.html +++ b/docs/reusing-specs/intersuite-spec-deps.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkIntersuite Spec Dependencies

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkIntersuite Spec Dependencies

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/reusing-specs/looping.html b/docs/reusing-specs/looping.html index b5155e5..7089cc3 100644 --- a/docs/reusing-specs/looping.html +++ b/docs/reusing-specs/looping.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkLooping

You can use the loop construct to loop through a list of items, each item generating a test.

When the loop property is specified, that spec will be run once for each item provided with the this.loopItem available in the lifecycle hooks (before_test and after_test).

The list of items can be specified in spec beforehand or you can specify a custom JS function which returns a list of items.

linkStatic Loop

Here's how a static loop is specified, type is static and loop list is mapped to static field as list of items.

specs/star-wars-static-loop.yml
1linkmeta:

2link name: Star Wars static loop

3linkconfiguration:

4link scheme: https

5link host: swapi.dev

6linkspecs:

7link - name: fetch each character

8link loop:

9link type: static

10link static:

11link - 1 # Luke Skywalker

12link - 4 # Darth Vader

13link before_test:

14link run_type: inline

15link inline:

16link function: !!js/function >

17link function() {

18link this.test.path_params = { userId : this.loopItem };

19link }

20link request:

21link path: /api/people/{userId}/ # <--- runs twice: once as "/api/people/1/" and once as "/api/people/4"

22link method: get

23link response:

24link status_code: 200

25link json_data:

26link - path: $.gender

27link value: male

See also: Example: Suite Using Loops



linkDynamic Loop Using JS

Here's how a static loop is specified, type is static and loop list is mapped to static field as list of items.

specs/star-wars-dynamic-loop.yml
1linkmeta:

2link name: Star Wars dynamic loop

3linkconfiguration:

4link scheme: https

5link host: swapi.dev

6linkspecs:

7link - name: fetch each character

8link loop:

9link type: dynamic

10link dynamic:

11link run_type: inline

12link inline:

13link function: !!js/function >

14link function() {

15link var generatePositiveInt = (max) => {

16link return Math.floor(Math.random() * max) + 1;

17link };

18link var runTimes = generatePositiveInt(10);

19link var items = [];

20link while (items.length < runTimes) {

21link items.push(generatePositiveInt());

22link }

23link return runTimes;

24link }

25link before_test:

26link run_type: inline

27link inline:

28link function: !!js/function >

29link function() {

30link this.test.path_params = { userId : this.loopItem };

31link }

32link request:

33link path: /api/people/{userId}/ # <--- runs random {n} times with random ID between 1 to 100

34link method: get

35link response:

36link status_code: 200

See also: Example: Suite Using Loops



linkAccessing Suite

Your dynamic loop can also utilize existing data saved on the this.suite context:

star-wars-suite-w-previous-data.yml
1linkmeta:

2link name: Star Wars dynamic suite with previous data

3linkconfiguration:

4link scheme: https

5link host: swapi.dev

6linkspecs:

7link - name: fetch a movie

8link request:

9link path: /api/films/1/

10link method: get

11link after_test:

12link run_type: inline

13link inline:

14link function: !!js/function >

15link function () {

16link const film = JSON.parse(this.response.body);

17link this.suite.characters = film.characters;

18link }

19link response:

20link status_code: 200

21link - name: fetch each character for the first film

22link loop:

23link type: dynamic

24link dynamic:

25link run_type: inline

26link inline:

27link # transform the list of URLs into a list of IDs

28link function: !!js/function >

29link function() {

30link return this.suite.characters.map((url) => {

31link var matches = url.match(/\/api\/people\/(\d+)\//);

32link return matches[1];

33link });

34link }

35link before_test:

36link run_type: inline

37link inline:

38link function: !!js/function >

39link function() {

40link this.test.path_params = { userId : this.loopItem };

41link }

42link request:

43link path: /api/people/{userId}/

44link method: get

45link response:

46link status_code: 200

47link after_test:

48link run_type: inline

49link inline:

50link function: !!js/function >

51link function() {

52link var character = JSON.parse(this.response.body);

53link console.log(character);

54link }



Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkLooping

You can use the loop construct to loop through a list of items, each item generating a test.

When the loop property is specified, that spec will be run once for each item provided with the this.loopItem available in the lifecycle hooks (before_test and after_test).

The list of items can be specified in spec beforehand or you can specify a custom JS function which returns a list of items.

linkStatic Loop

Here's how a static loop is specified, type is static and loop list is mapped to static field as list of items.

specs/star-wars-static-loop.yml
1linkmeta:

2link name: Star Wars static loop

3linkconfiguration:

4link scheme: https

5link host: swapi.dev

6linkspecs:

7link - name: fetch each character

8link loop:

9link type: static

10link static:

11link - 1 # Luke Skywalker

12link - 4 # Darth Vader

13link before_test:

14link run_type: inline

15link inline:

16link function: !!js/function >

17link function() {

18link this.test.path_params = { userId : this.loopItem };

19link }

20link request:

21link path: /api/people/{userId}/ # <--- runs twice: once as "/api/people/1/" and once as "/api/people/4"

22link method: get

23link response:

24link status_code: 200

25link json_data:

26link - path: $.gender

27link value: male

See also: Example: Suite Using Loops



linkDynamic Loop Using JS

Here's how a static loop is specified, type is static and loop list is mapped to static field as list of items.

specs/star-wars-dynamic-loop.yml
1linkmeta:

2link name: Star Wars dynamic loop

3linkconfiguration:

4link scheme: https

5link host: swapi.dev

6linkspecs:

7link - name: fetch each character

8link loop:

9link type: dynamic

10link dynamic:

11link run_type: inline

12link inline:

13link function: !!js/function >

14link function() {

15link var generatePositiveInt = (max) => {

16link return Math.floor(Math.random() * max) + 1;

17link };

18link var runTimes = generatePositiveInt(10);

19link var items = [];

20link while (items.length < runTimes) {

21link items.push(generatePositiveInt());

22link }

23link return runTimes;

24link }

25link before_test:

26link run_type: inline

27link inline:

28link function: !!js/function >

29link function() {

30link this.test.path_params = { userId : this.loopItem };

31link }

32link request:

33link path: /api/people/{userId}/ # <--- runs random {n} times with random ID between 1 to 100

34link method: get

35link response:

36link status_code: 200

See also: Example: Suite Using Loops



linkAccessing Suite

Your dynamic loop can also utilize existing data saved on the this.suite context:

star-wars-suite-w-previous-data.yml
1linkmeta:

2link name: Star Wars dynamic suite with previous data

3linkconfiguration:

4link scheme: https

5link host: swapi.dev

6linkspecs:

7link - name: fetch a movie

8link request:

9link path: /api/films/1/

10link method: get

11link after_test:

12link run_type: inline

13link inline:

14link function: !!js/function >

15link function () {

16link const film = JSON.parse(this.response.body);

17link this.suite.characters = film.characters;

18link }

19link response:

20link status_code: 200

21link - name: fetch each character for the first film

22link loop:

23link type: dynamic

24link dynamic:

25link run_type: inline

26link inline:

27link # transform the list of URLs into a list of IDs

28link function: !!js/function >

29link function() {

30link return this.suite.characters.map((url) => {

31link var matches = url.match(/\/api\/people\/(\d+)\//);

32link return matches[1];

33link });

34link }

35link before_test:

36link run_type: inline

37link inline:

38link function: !!js/function >

39link function() {

40link this.test.path_params = { userId : this.loopItem };

41link }

42link request:

43link path: /api/people/{userId}/

44link method: get

45link response:

46link status_code: 200

47link after_test:

48link run_type: inline

49link inline:

50link function: !!js/function >

51link function() {

52link var character = JSON.parse(this.response.body);

53link console.log(character);

54link }



Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/reusing-specs/overview.html b/docs/reusing-specs/overview.html index 9874620..1bc5e23 100644 --- a/docs/reusing-specs/overview.html +++ b/docs/reusing-specs/overview.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkReusing Specs & DRY Techniques

REST-EZ has several features aimed at code re-use:

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkReusing Specs & DRY Techniques

REST-EZ has several features aimed at code re-use:

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/reusing-specs/run-spec-in-js.html b/docs/reusing-specs/run-spec-in-js.html index 7443bdb..461a3ac 100644 --- a/docs/reusing-specs/run-spec-in-js.html +++ b/docs/reusing-specs/run-spec-in-js.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkRun Existing Specs Using JS

REST-EZ supports re-using specs & their result via the this.runSpec() method



linkSpec in the Same Suite File

You can re-use an existing spec in your suite with JS:

star-wars-api-using-spec-in-same-file.yml
1linkmeta:

2link name: star wars api using yaml anchors

3linkconfiguration:

4link scheme: http

5link host: swapi.dev

6linkspecs:

7link - name: fetch film by film ID

8link request:

9link path: /api/films/{filmId}/

10link method: get

11link path_params:

12link - name: filmId

13link value: 1

14link response:

15link status_code: 200

16link - name: fetch person for film 2

17link request:

18link path: /api/people/{personId}/

19link method: get

20link before_test:

21link run_type: inline

22link inline:

23link function: !js/asyncFunction >

24link async function() {

25link var response = await this.runSpec('fetch film by film ID');

26link // name: "A New Hope"

27link this.suite.film = JSON.parse(response.body);

28link var characterUrl = this.suite.film.characters[0];

29link var personId = characterUrl.match(/\/api\/people\/(\d+)\//)[1];

30link this.test.path_params = { personId };

31link }

32link response:

33link status_code: 200



linkSpec Within a Different Suite File

Intrasuite dependencies can be specified to allow using specs in a different suite

Use the spec_dependencies suite-level property to enable this. Paths are relative to current working directory of Node process.

ℹ️ NOTE: that these imported specs will only be available when you run them using this.runSpec.



specs/new-suite.yml
1linkmeta:

2link name: Suite Relying on a Dependency

3linkspec_dependencies:

4link - specs/existing-suite.yml

5linkconfiguration:

6link scheme: http

7link host: swapi.dev

8linkspecs:

9link - name: fetch person for film 2

10link request:

11link path: /api/people/{personId}/

12link method: get

13link before_test:

14link run_type: inline

15link inline:

16link function: !js/asyncFunction >

17link async function() {

18link var response = await this.runSpec('fetch film by film ID');

19link // name: "A New Hope"

20link this.suite.film = JSON.parse(response.body);

21link var characterUrl = this.suite.film.characters[0];

22link var personId = characterUrl.match(/\/api\/people\/(\d+)\//)[1];

23link this.test.path_params = { personId };

24link }

25link response:

26link status_code: 200

specs/existing-suite.yml
1linkmeta:

2link name: Suite With an Existing Spec

3linkconfiguration:

4link scheme: http

5link host: swapi.dev

6linkspecs:

7link - name: fetch film by film ID

8link request:

9link path: /api/films/{filmId}/

10link method: get

11link path_params:

12link - name: filmId

13link value: 1

14link response:

15link status_code: 200



💡 To use a path relative to suite's path, use the locate_files_relative parameter of the suite meta section.



See also: Example: Run Specs from External File



linkspec_dependencies

  • Type: array optional

Root-level suite property.

A list of file paths that this suite relies on to use runSpec method.

1linkspec_dependencies:

2link - specs/some-suite.yml

3link - specs/some-other-suite.yml

4link# ...



linkThe runSpec Method

runSpec(name, options)

  • name string required Name of spec to run (identified by name property of the spec)
  • options object optional Override the original spec (e.g. headers, query_params, path_params, etc.)

Returns Promise<Response> The response generated by the spec

1link/**

2link * Run an existing spec in this suite

3link * or an external suite connected via interspec_dependencies suite config

4link *

5link * @param {string} specName Name of spec to run (identified by `name` property of the spec)

6link * @param {object} options Override the original spec

7link * @param {string} options.path The URL

8link * @param {string} options.method HTTP request method

9link * @param {array} options.headers Object of key/value pairs to set as headers

10link * @param {array} options.path_params Object of key/value pairs to set in the path

11link * @param {array} options.query_params Object of key/value pairs to add as query params ?name=value&name2=value2

12link * @param {object} options.payload Request body payload

13link *

14link * @return Promise<Response>

15link */

16linkfunction runSpec(specName, options) { }

example-spec.yml
1link# ...

2link - name: generate auth token

3link request:

4link path: /auth/login

5link method: post

6link payload:

7link body:

8link type: json

9link content:

10link email: foo@bar.com

11link password: F2#@9!mls

12link response:

13link status_code: 201

14link json_data:

15link - name: $.token

16link value: !!js/regexp /^[A-Z0-9]{32}$

17link - name: fetch a person

18link request:

19link path: /user

20link method: get

21link before_test:

22link run_type: inline

23link inline:

24link function: !js/asyncFunction >

25link async function() {

26link var response = await this.runSpec('generate auth token');

27link var { token } = JSON.parse(response.body);

28link this.test.headers = {

29link 'Authorization': `Bearer ${token}`

30link };

31link }

32link response:

33link status_code: 200

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkRun Existing Specs Using JS

REST-EZ supports re-using specs & their result via the this.runSpec() method



linkSpec in the Same Suite File

You can re-use an existing spec in your suite with JS:

star-wars-api-using-spec-in-same-file.yml
1linkmeta:

2link name: star wars api using yaml anchors

3linkconfiguration:

4link scheme: http

5link host: swapi.dev

6linkspecs:

7link - name: fetch film by film ID

8link request:

9link path: /api/films/{filmId}/

10link method: get

11link path_params:

12link - name: filmId

13link value: 1

14link response:

15link status_code: 200

16link - name: fetch person for film 2

17link request:

18link path: /api/people/{personId}/

19link method: get

20link before_test:

21link run_type: inline

22link inline:

23link function: !js/asyncFunction >

24link async function() {

25link var response = await this.runSpec('fetch film by film ID');

26link // name: "A New Hope"

27link this.suite.film = JSON.parse(response.body);

28link var characterUrl = this.suite.film.characters[0];

29link var personId = characterUrl.match(/\/api\/people\/(\d+)\//)[1];

30link this.test.path_params = { personId };

31link }

32link response:

33link status_code: 200



linkSpec Within a Different Suite File

Intrasuite dependencies can be specified to allow using specs in a different suite

Use the spec_dependencies suite-level property to enable this. Paths are relative to current working directory of Node process.

ℹ️ NOTE: that these imported specs will only be available when you run them using this.runSpec.



specs/new-suite.yml
1linkmeta:

2link name: Suite Relying on a Dependency

3linkspec_dependencies:

4link - specs/existing-suite.yml

5linkconfiguration:

6link scheme: http

7link host: swapi.dev

8linkspecs:

9link - name: fetch person for film 2

10link request:

11link path: /api/people/{personId}/

12link method: get

13link before_test:

14link run_type: inline

15link inline:

16link function: !js/asyncFunction >

17link async function() {

18link var response = await this.runSpec('fetch film by film ID');

19link // name: "A New Hope"

20link this.suite.film = JSON.parse(response.body);

21link var characterUrl = this.suite.film.characters[0];

22link var personId = characterUrl.match(/\/api\/people\/(\d+)\//)[1];

23link this.test.path_params = { personId };

24link }

25link response:

26link status_code: 200

specs/existing-suite.yml
1linkmeta:

2link name: Suite With an Existing Spec

3linkconfiguration:

4link scheme: http

5link host: swapi.dev

6linkspecs:

7link - name: fetch film by film ID

8link request:

9link path: /api/films/{filmId}/

10link method: get

11link path_params:

12link - name: filmId

13link value: 1

14link response:

15link status_code: 200



💡 To use a path relative to suite's path, use the locate_files_relative parameter of the suite meta section.



See also: Example: Run Specs from External File



linkspec_dependencies

  • Type: array optional

Root-level suite property.

A list of file paths that this suite relies on to use runSpec method.

1linkspec_dependencies:

2link - specs/some-suite.yml

3link - specs/some-other-suite.yml

4link# ...



linkThe runSpec Method

runSpec(name, options)

  • name string required Name of spec to run (identified by name property of the spec)
  • options object optional Override the original spec (e.g. headers, query_params, path_params, etc.)

Returns Promise<Response> The response generated by the spec

1link/**

2link * Run an existing spec in this suite

3link * or an external suite connected via interspec_dependencies suite config

4link *

5link * @param {string} specName Name of spec to run (identified by `name` property of the spec)

6link * @param {object} options Override the original spec

7link * @param {string} options.path The URL

8link * @param {string} options.method HTTP request method

9link * @param {array} options.headers Object of key/value pairs to set as headers

10link * @param {array} options.path_params Object of key/value pairs to set in the path

11link * @param {array} options.query_params Object of key/value pairs to add as query params ?name=value&name2=value2

12link * @param {object} options.payload Request body payload

13link *

14link * @return Promise<Response>

15link */

16linkfunction runSpec(specName, options) { }

example-spec.yml
1link# ...

2link - name: generate auth token

3link request:

4link path: /auth/login

5link method: post

6link payload:

7link body:

8link type: json

9link content:

10link email: foo@bar.com

11link password: F2#@9!mls

12link response:

13link status_code: 201

14link json_data:

15link - name: $.token

16link value: !!js/regexp /^[A-Z0-9]{32}$

17link - name: fetch a person

18link request:

19link path: /user

20link method: get

21link before_test:

22link run_type: inline

23link inline:

24link function: !js/asyncFunction >

25link async function() {

26link var response = await this.runSpec('generate auth token');

27link var { token } = JSON.parse(response.body);

28link this.test.headers = {

29link 'Authorization': `Bearer ${token}`

30link };

31link }

32link response:

33link status_code: 200

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/reusing-specs/yaml-anchors.html b/docs/reusing-specs/yaml-anchors.html index 2d65cb4..cf0c1a5 100644 --- a/docs/reusing-specs/yaml-anchors.html +++ b/docs/reusing-specs/yaml-anchors.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

linkYaml Anchors & Pointers

Yaml itself has powerful features built-in to allow re-use of defined data.

The & defines a named anchor and * references it.

See also: Yaml Anchors Explained

1linkmeta:

2link name: star wars api using yaml anchors

3linkconfiguration:

4link scheme: http

5link host: swapi.dev

6linkspecs:

7link - name: fetch person 1

8link request: &starwars_person_request

9link path: /api/people/{personId}/

10link method: get

11link response: &starwars_person_response

12link status_code: 200

13link json_schema:

14link type: inline

15link $ref: >

16link {

17link "type": "object",

18link "properties": {

19link "films": {

20link "type": "array",

21link "items": {

22link "type": "string"

23link }

24link }

25link },

26link "required": ["films"]

27link }

28link before_test:

29link run_type: inline

30link inline:

31link function: !!js/function >

32link function() {

33link this.test.path_params = { personId: 1};

34link }

35link after_test: &log_body

36link run_type: inline

37link inline:

38link function: !!js/function >

39link function() {

40link console.log(this.response.body);

41link }

42link

43link - name: fetch person 2

44link request: *starwars_person_request

45link response: *starwars_person_response

46link before_test:

47link run_type: inline

48link inline:

49link function: !!js/function >

50link function() {

51link this.test.path_params = { personId: 2};

52link }

53link after_test: *log_body

54link

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

linkYaml Anchors & Pointers

Yaml itself has powerful features built-in to allow re-use of defined data.

The & defines a named anchor and * references it.

See also: Yaml Anchors Explained

1linkmeta:

2link name: star wars api using yaml anchors

3linkconfiguration:

4link scheme: http

5link host: swapi.dev

6linkspecs:

7link - name: fetch person 1

8link request: &starwars_person_request

9link path: /api/people/{personId}/

10link method: get

11link response: &starwars_person_response

12link status_code: 200

13link json_schema:

14link type: inline

15link $ref: >

16link {

17link "type": "object",

18link "properties": {

19link "films": {

20link "type": "array",

21link "items": {

22link "type": "string"

23link }

24link }

25link },

26link "required": ["films"]

27link }

28link before_test:

29link run_type: inline

30link inline:

31link function: !!js/function >

32link function() {

33link this.test.path_params = { personId: 1};

34link }

35link after_test: &log_body

36link run_type: inline

37link inline:

38link function: !!js/function >

39link function() {

40link console.log(this.response.body);

41link }

42link

43link - name: fetch person 2

44link request: *starwars_person_request

45link response: *starwars_person_response

46link before_test:

47link run_type: inline

48link inline:

49link function: !!js/function >

50link function() {

51link this.test.path_params = { personId: 2};

52link }

53link after_test: *log_body

54link

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/docs/reusing-specs/yaml-pointers.html b/docs/reusing-specs/yaml-pointers.html index 9170c00..55c58db 100644 --- a/docs/reusing-specs/yaml-pointers.html +++ b/docs/reusing-specs/yaml-pointers.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file diff --git a/index.html b/index.html index e02adf2..874ea47 100644 --- a/index.html +++ b/index.html @@ -35,43 +35,43 @@ .icon-font.outline { font-family: 'Material Icons Outlined'; } -

REST-EZ

REST-EZ

linkOverview

linkWhat is it?

REST-EZ is a declarative, specification based test framework for HTTP (ex: REST & GraphQL) APIs. In short, you test APIs without writing code (declarative, not procedural).

linkHow does it work?

YAML files define sets of requests & response validations

Each suite can have one or more specs. For each spec, REST-EZ:

  1. Builds the request
  2. Sends the request to the server
  3. Validates the response

linkDocumentation

linkAcknowledgements

👏👏👏 Enormous thanks to Kiran Mandadi,

Original creator of rest-ez upon which this project is based (forked).

👏👏👏 Thanks to corporate sponsors

linkRoadmap & TODO

  • Full support for de-referencing schema $refs
  • Allow specifying node within a schema file using JSON pointer
  • Pass arguments to inline or module-based functions to allow creater re-use
  • Documentation improvements
    • Upgrade markdown static site generator (something without python dependency)
    • Example function with arguments usage
    • JSON schema validation de-referencing schema $refs
    • Specify node within a schema file using JSON path
    • Examples directly using files within node_modules
  • Example of how to use faker.js using reusable function
  • Code Quality - add linter/hinter/prettier or whatever spec is used

Home

Getting Startedchevron_right
Basicschevron_right

Overview +

REST-EZ

REST-EZ

linkOverview

linkWhat is it?

REST-EZ is a declarative, specification based test framework for HTTP (ex: REST & GraphQL) APIs. In short, you test APIs without writing code (declarative, not procedural).

linkHow does it work?

YAML files define sets of requests & response validations

Each suite can have one or more specs. For each spec, REST-EZ:

  1. Builds the request
  2. Sends the request to the server
  3. Validates the response

linkDocumentation

linkAcknowledgements

👏👏👏 Enormous thanks to Kiran Mandadi,

Original creator of rest-ez upon which this project is based (forked).

👏👏👏 Thanks to corporate sponsors

linkRoadmap & TODO

  • Full support for de-referencing schema $refs
  • Allow specifying node within a schema file using JSON pointer
  • Pass arguments to inline or module-based functions to allow creater re-use
  • Documentation improvements
    • Upgrade markdown static site generator (something without python dependency)
    • Example function with arguments usage
    • JSON schema validation de-referencing schema $refs
    • Specify node within a schema file using JSON path
    • Examples directly using files within node_modules
  • Example of how to use faker.js using reusable function
  • Code Quality - add linter/hinter/prettier or whatever spec is used

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters -Path Parameters

Payload Bodychevron_right

JSON Body +Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry -Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right
Response Validationchevron_right

Overview

Assertionschevron_right

Status Code -Headers & Cookies

Bodychevron_right

Overview +Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right
Command Line Interface (CLI)chevron_right
\ No newline at end of file +Reporters

\ No newline at end of file