@@ -89,7 +89,7 @@ Given(/^I am authenticating as "([^"]*)" with "([^"]*)" password$/, function (us
8989 * Example #2: Given I set header "Authorization" with value "Bearer token123"
9090 * Example #3: Given I set header "Accept" with value "application/xml"
9191 */
92- Given ( / ^ I s e t h e a d e r " ( [ ^ " ] * ) " w i t h v a l u e " ( [ ^ " ] * ) " $ / , function ( name , value ) {
92+ Given ( / ^ (?: I | w e ) ? s e t h e a d e r " ( [ ^ " ] * ) " w i t h v a l u e " ( [ ^ " ] * ) " $ / , function ( name , value ) {
9393 apiHeaders [ name ] = replacePlaceHolder ( value ) ;
9494} ) ;
9595
@@ -111,7 +111,7 @@ Given(/^(?:the API base URL is|I set the API base URL to|the base URL is) "([^"]
111111 * Example #2: Given I set the header "Authorization" to "Bearer token123"
112112 * Example #3: Given the header "Accept" is "application/json"
113113 */
114- Given ( / ^ (?: I s e t t h e h e a d e r | t h e h e a d e r ) " ( [ ^ " ] * ) " (?: t o | i s ) " ( [ ^ " ] * ) " $ / , function ( headerName , headerValue ) {
114+ Given ( / ^ (?: I s e t t h e h e a d e r | w e s e t t h e h e a d e r | t h e h e a d e r ) " ( [ ^ " ] * ) " (?: t o | i s ) " ( [ ^ " ] * ) " $ / , function ( headerName , headerValue ) {
115115 apiHeaders [ headerName ] = replacePlaceHolder ( headerValue ) ;
116116} ) ;
117117
@@ -123,7 +123,7 @@ Given(/^(?:I set the header|the header) "([^"]*)" (?:to|is) "([^"]*)"$/, functio
123123 * | Authorization | Bearer token123 |
124124 * | Accept | application/json |
125125 */
126- Given ( / ^ I s e t t h e f o l l o w i n g h e a d e r s : $ / , function ( table ) {
126+ Given ( / ^ (?: I | w e ) s e t t h e f o l l o w i n g h e a d e r s : $ / , function ( table ) {
127127 table . rows ( ) . forEach ( row => {
128128 apiHeaders [ row [ 0 ] ] = replacePlaceHolder ( row [ 1 ] ) ;
129129 } ) ;
@@ -135,7 +135,7 @@ Given(/^I set the following headers:$/, function (table) {
135135 * Example #1: Given I set the request body to '{"name": "John", "email": "john@example .com"}'
136136 * Example #2: Given the request body is '{"title": "Test Post", "body": "This is a test"}'
137137 */
138- Given ( / ^ (?: I s e t t h e r e q u e s t b o d y t o | t h e r e q u e s t b o d y i s ) ' ( [ ^ ' ] * ) ' $ / , function ( jsonData ) {
138+ Given ( / ^ (?: I s e t t h e r e q u e s t b o d y t o | w e s e t t h e r e q u e s t b o d y t o | t h e r e q u e s t b o d y i s ) ' ( [ ^ ' ] * ) ' $ / , function ( jsonData ) {
139139 try {
140140 const processedData = replacePlaceHolder ( jsonData ) ;
141141 apiRequestData = JSON . parse ( processedData ) ;
@@ -152,7 +152,7 @@ Given(/^(?:I set the request body to|the request body is) '([^']*)'$/, function
152152153153 * | age | 30 |
154154 */
155- Given ( / ^ I s e t t h e r e q u e s t b o d y w i t h : $ / , function ( table ) {
155+ Given ( / ^ (?: I | w e ) s e t t h e r e q u e s t b o d y w i t h : $ / , function ( table ) {
156156 apiRequestData = { } ;
157157 table . rows ( ) . forEach ( row => {
158158 let value = replacePlaceHolder ( row [ 1 ] ) ;
@@ -170,11 +170,11 @@ Given(/^I set the request body with:$/, function (table) {
170170 * Sends HTTP request to specific relative URL.
171171 *
172172 * Example #1: When I send a GET request to "/users"
173- * Example #2: When I send a POST request to "/posts"
173+ * Example #2: When we send a POST request to "/posts"
174174 * Example #3: When I send a PUT request to "/users/1"
175- * Example #4: When I send a DELETE request to "/posts/1"
175+ * Example #4: When we send a DELETE request to "/posts/1"
176176 */
177- When ( / ^ (?: I ) ? s e n d a ( [ A - Z ] + ) r e q u e s t t o " ( [ ^ " ] + ) " $ / , async function ( method , endpoint ) {
177+ When ( / ^ (?: I | w e ) ? s e n d a ( [ A - Z ] + ) r e q u e s t t o " ( [ ^ " ] + ) " $ / , async function ( method , endpoint ) {
178178 const url = baseURL + '/' + prepareUrl ( endpoint ) ;
179179
180180 try {
@@ -196,11 +196,12 @@ When(/^(?:I )?send a ([A-Z]+) request to "([^"]+)"$/, async function (method, en
196196 * Sends HTTP request to specific URL with field values from Table.
197197 *
198198 * Example: When I send a POST request to "/users" with values:
199+ * When we send a POST request to "/users" with values:
199200 * | name | John Doe |
200201201202 * | age | 30 |
202203 */
203- When ( / ^ (?: I ) ? s e n d a ( [ A - Z ] + ) r e q u e s t t o " ( [ ^ " ] + ) " w i t h v a l u e s : $ / , async function ( method , endpoint , table ) {
204+ When ( / ^ (?: I | w e ) ? s e n d a ( [ A - Z ] + ) r e q u e s t t o " ( [ ^ " ] + ) " w i t h v a l u e s : $ / , async function ( method , endpoint , table ) {
204205 const url = baseURL + '/' + prepareUrl ( endpoint ) ;
205206 const fields = { } ;
206207
@@ -228,14 +229,15 @@ When(/^(?:I )?send a ([A-Z]+) request to "([^"]+)" with values:$/, async functio
228229 * Sends HTTP request to specific URL with raw body from PyString.
229230 *
230231 * Example: When I send a POST request to "/users" with body:
232+ * When we send a POST request to "/users" with body:
231233 * """
232234 * {
233235 * "name": "John Doe",
234236 * "email": "john@example .com"
235237 * }
236238 * """
237239 */
238- When ( / ^ (?: I ) ? s e n d a ( [ A - Z ] + ) r e q u e s t t o " ( [ ^ " ] + ) " w i t h b o d y : $ / , async function ( method , endpoint , docString ) {
240+ When ( / ^ (?: I | w e ) ? s e n d a ( [ A - Z ] + ) r e q u e s t t o " ( [ ^ " ] + ) " w i t h b o d y : $ / , async function ( method , endpoint , docString ) {
239241 const url = baseURL + '/' + prepareUrl ( endpoint ) ;
240242 const body = replacePlaceHolder ( docString . trim ( ) ) ;
241243
@@ -276,13 +278,14 @@ When(/^(?:I )?send a ([A-Z]+) request to "([^"]+)" with body:$/, async function
276278 * Sends HTTP request to specific URL with form data.
277279 *
278280 * Example: When I send a POST request to "/login" with form data:
281+ * When we send a POST request to "/login" with form data:
279282 * """
280283 * username=admin
281284 * password=secret
282285 * remember=true
283286 * """
284287 */
285- When ( / ^ (?: I ) ? s e n d a ( [ A - Z ] + ) r e q u e s t t o " ( [ ^ " ] + ) " w i t h f o r m d a t a : $ / , async function ( method , endpoint , docString ) {
288+ When ( / ^ (?: I | w e ) ? s e n d a ( [ A - Z ] + ) r e q u e s t t o " ( [ ^ " ] + ) " w i t h f o r m d a t a : $ / , async function ( method , endpoint , docString ) {
286289 const url = baseURL + '/' + prepareUrl ( endpoint ) ;
287290 const body = replacePlaceHolder ( docString . trim ( ) ) ;
288291
@@ -530,6 +533,6 @@ Then(/^print API response$/, function () {
530533 *
531534 * Example: Given I set placeholder "{{userId}}" to "123"
532535 */
533- Given ( / ^ I s e t p l a c e h o l d e r " ( [ ^ " ] * ) " t o " ( [ ^ " ] * ) " $ / , function ( placeholder , value ) {
536+ Given ( / ^ (?: I | w e ) s e t p l a c e h o l d e r " ( [ ^ " ] * ) " t o " ( [ ^ " ] * ) " $ / , function ( placeholder , value ) {
534537 placeHolders [ placeholder ] = value ;
535538} ) ;
0 commit comments