Skip to content

Commit

Permalink
Preparation for releasing 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vasan-agrostar committed Jun 2, 2024
1 parent a4c9627 commit e56f20b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Change Log

## [1.2.0]
- Bug fix: stopOnFailue not working
## 1.3.0
- Support for `$tests` to recursively run tests on a sub-object

## [1.2.1]
- Bug fix: stopOnFailure not working

## [1.2.0]
- Support `$sw`, `$ew`, `$co` for startsWith, endsWith and contains
Expand Down
4 changes: 2 additions & 2 deletions docs/zzapi-bundle-description.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ Operators supported in the RHS are:
* `$size`: for length of arrays and objects, or the length of the string if it is not an array. The value can be an object for `$ne`, `$lt` etc. comparisons.
* `$exists`: true|false, to check existance of a field
* `$type`: string|number|object|array|null: to check the type of the field
* `$tests`: perform assertions (recursively) on the value, as if it were the `$.` root

### jsonpath tests

Expand All @@ -183,11 +184,10 @@ Object | Path | Result
`{ field: [ { value: 10 }, { value: 20 } ]}` | `$.field.1.value` | 20
`{ field: [ { name: x, value: 10 }, { name: y, value: 20 } ]}` | `$.field[?(@.name=="x")].value` | 10

If the result is a non-scalar (eg, the entire array) it will be used as is when matching against the operators `$size`, `$exists` and `$type`, otherwise will be converted to a string using `JSON.stringify(value)`.
If the result is a non-scalar (eg, the entire array) it will be used as is when matching against the operators `$tests`, `$size`, `$exists` and `$type`, otherwise will be converted to a string using `JSON.stringify(value)`.

### setvars

Values from the response (headers and JSON body) can be captured and set as variables. We allow variables which are not scalars also (eg, objects and arrays), when capturing values from the response JSON.

`setvars` is an object with many ke-value pairs, where the key is the name of the variable to set and the value is similar to tests: one of status, entire body, a JSONPATH spec or a header spec.

16 changes: 11 additions & 5 deletions examples/tests-bundle.zzb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# yaml-language-server: $schema=../schemas/zzapi-bundle.schema.json

# This bundle contains a series of test requests against various endpoints,
# most of them being the postman echo service. We use this to both serve as
# an example of how to create test bundles as well as testing zzapi runner itself.
# an example of how to create test bundles as well as testing zzapi itself.

common:
baseUrl: https://postman-echo.com
Expand Down Expand Up @@ -240,14 +241,19 @@ requests:
$.data.phoneNumbers[0].type: mobile
$.data.phoneNumbers.1.type: home
$.data.phoneNumbers[?(@.type=="home")].number: 0123-4567-8910
$.data.lastName: { $exists: true }
# $.data.middleName: { $exists: true, $type: "null" }
$.data.middleName: null
$.data.otherName: { $exists: false, $type: undefined }
$.data.phoneNumbers[*].type: mobile
$.data.phoneNumbers[*].available: { $eq: [7, 22] }
$.data.phoneNumbers.0.available: { $eq: [7, 22], $type: array }
$.data.phoneNumbers.1.available: { $eq: "[18,22]", $type: array }
$.data.phoneNumbers.0:
$tests:
$.type: mobiles
$.number: { $ne: 0123-4567-8910 }
$.available: { $eq: [7, 22] }
$.data.lastName: { $exists: true }
# $.data.middleName: { $exists: true, $type: "null" }
$.data.middleName: null
$.data.otherName: { $exists: false, $type: undefined }
# stress: ensure corner cases don't crash
$.data.otherName.value: { $exists: false } # don't recurse down undefined
$.data.middleName.value: { $exists: false } # don't recurse down null
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zzapi",
"version": "1.2.1",
"version": "1.3.0",
"description": "zzAPI is a REST API testing and documentation tool set. It is an open-source Postman alternative. ",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
3 changes: 2 additions & 1 deletion schemas/zzapi-bundle.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
}
}
]
}
},
"$tests": { "$ref": "#/$defs/tests" }
}
}
]
Expand Down

0 comments on commit e56f20b

Please sign in to comment.