@@ -42,7 +42,7 @@ Then('I see response status {int}', Then_I_see_response_status);
4242 * @example
4343 *
4444 * ```gherkin
45- * Then I see response body "OK
45+ * Then I see response body "OK"
4646 * ```
4747 *
4848 * @remarks
@@ -57,11 +57,48 @@ Then('I see response status {int}', Then_I_see_response_status);
5757export function Then_I_see_response_body ( body : string ) {
5858 getCypressElement ( ) . should ( ( response : Cypress . Response < object > ) => {
5959 if ( typeof response . body === 'object' ) {
60- expect ( response . body ) . to . eql ( JSON . parse ( body ) ) ;
60+ expect ( response . body ) . to . deep . equal ( JSON . parse ( body ) ) ;
6161 } else {
6262 expect ( response . body ) . to . equal ( body ) ;
6363 }
6464 } ) ;
6565}
6666
6767Then ( 'I see response body {string}' , Then_I_see_response_body ) ;
68+
69+ /**
70+ * Then I see response body contains:
71+ *
72+ * ```gherkin
73+ * Then I see response body contains {string}
74+ * ```
75+ *
76+ * @example
77+ *
78+ * ```gherkin
79+ * Then I see response body contains "OK"
80+ * ```
81+ *
82+ * @remarks
83+ *
84+ * A preceding step like {@link When_I_make_a_request | "When I make a request"} is required. For example:
85+ *
86+ * ```gherkin
87+ * When I make a "GET" request to "/user.json"
88+ * Then I see response body contains '{"name":"Mark"}'
89+ * ```
90+ */
91+ export function Then_I_see_response_body_contains ( body : string ) {
92+ getCypressElement ( ) . should ( ( response : Cypress . Response < object > ) => {
93+ if ( typeof response . body === 'object' ) {
94+ expect ( response . body ) . to . deep . include ( JSON . parse ( body ) ) ;
95+ } else {
96+ expect ( response . body ) . to . include ( body ) ;
97+ }
98+ } ) ;
99+ }
100+
101+ Then (
102+ 'I see response body contains {string}' ,
103+ Then_I_see_response_body_contains ,
104+ ) ;
0 commit comments