You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Headers**: expected headers as a map (only defined headers are tested)
68
-
-**Body**: expected text body
69
-
-**Json**: expected JSON body as a structure
70
-
-**JsonExcludes**: a list of paths to excludes from test in JSON response
66
+
-**statusCode**: expected status code
67
+
-**headers**: expected headers as a map (only defined headers are tested)
68
+
-**headersRegexps**: list of headers assertions that are regexps
69
+
-**body**: expected text body
70
+
-**bodyRegexp**: regexp for expected body
71
+
-**json**: expected JSON body as a structure
72
+
-**jsonExcludes**: a list of paths to excludes from test in JSON response
73
+
-**jsonRegexps**: list of json fields assertions that are regexps
71
74
72
75
Fields that are not set are not checked. Only defined headers are checked, thus Tavern executor won't complain about an additional header.
73
76
77
+
## Json Excludes
78
+
74
79
You can exclude paths from JSON during test. For instance, to exclude field `CreationDate` during response comparison, you might add in `response` field:
75
80
76
81
```yaml
@@ -105,6 +110,37 @@ Thus:
105
110
- **\*** matches any entry
106
111
- **\*\*** matches any entries in successive levels
107
112
113
+
## Regular Expressions
114
+
115
+
You can perform assertions with regular expressions.
116
+
117
+
To perform a body assertion with regular expression, you can use `bodyRegexp`. Thus you might write:
118
+
119
+
```yaml
120
+
bodyRegexp: "Foo.*Bar"
121
+
```
122
+
123
+
To perform regexp assertions on headers, you must declare headers to assert in `headers` clause, then list regexp fields in `headersRegexps`, as follows:
To perform regexp assertions on JSON structure, you must declare fields to assert in `json` clause, then list regexp fields in `jsonRegexps`, as follows:
133
+
134
+
```yaml
135
+
json:
136
+
foo: "bar"
137
+
spam: "e.*s"
138
+
jsonRegexps:
139
+
- "spam"
140
+
```
141
+
142
+
This will assert that *spam* JSON field matches `e.*s` regexp. Assertion on *foo* fields will be performed with equality as usual.
0 commit comments