diff --git a/SCHEMA.md b/SCHEMA.md index b87c86f..5175479 100644 --- a/SCHEMA.md +++ b/SCHEMA.md @@ -15,6 +15,7 @@ - [`postData`](#postdata) - [`mimeType`](#mimetype) - [`text`](#text) + - [`params`](#params) - [`queryString`](#querystring) - [`headers`](#headers) - [`auth`](#auth) diff --git a/src/configSchema.ts b/src/configSchema.ts index 218d499..84a96e4 100644 --- a/src/configSchema.ts +++ b/src/configSchema.ts @@ -137,10 +137,14 @@ interface cookiesObjectSchema { name: string, value: string, } +interface paramsObjectSchema { + name: string, + value: string, +} interface postDataObjectSchema { mimeType: string, - params: object, + params: Array, text : string, comment: string, } diff --git a/src/test.ts b/src/test.ts index 383300b..db3f47e 100644 --- a/src/test.ts +++ b/src/test.ts @@ -405,6 +405,11 @@ const performRequest = async (requestObject: requestsObjectSchema, requestName: if (requestObject.request.postData.text) { axiosObject.data = requestObject.request.postData.text; } + if (requestObject.request.postData.params) { + const searchParams = new URLSearchParams() + requestObject.request.postData.params.forEach(item=>{searchParams.append(item.name,item.value)}) + axiosObject.data = searchParams.toString(); + } } try { diff --git a/tests/success/params/post.strest.yml b/tests/success/params/post.strest.yml new file mode 100644 index 0000000..e96deff --- /dev/null +++ b/tests/success/params/post.strest.yml @@ -0,0 +1,19 @@ +version: 2 + +requests: + postwithparams: + request: + url: https://postman-echo.com/post + method: POST + postData: + mimeType: application/x-www-form-urlencoded + params: + - name: title + value: foo + - name: body + value: bar + - name: userId + value: "1" + validate: + - jsonpath: content.json.title + expect: foo \ No newline at end of file