Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #131 from eykrehbein/features
Browse files Browse the repository at this point in the history
features and fixes
  • Loading branch information
jgroom33 authored Jan 24, 2019
2 parents 064861c + d81280d commit 0af282f
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@strest/cli",
"version": "2.3.1",
"version": "2.4.0",
"description": "A new dimension of REST API testing",
"main": "dist/main.js",
"repository": "https://github.com/eykrehbein/strest",
Expand Down
2 changes: 1 addition & 1 deletion src/configSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const paramsSchema = Joi.object().keys({
})

const postDataSchema = Joi.object().keys({
mimeType: Joi.string().required().valid('application/json', 'text/plain'),
mimeType: Joi.string().required(),
params: Joi.array().items(paramsSchema).optional(),
text : Joi.alternatives().try(Joi.object(), Joi.string()).optional(),
comment: Joi.string().optional(),
Expand Down
8 changes: 7 additions & 1 deletion src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ export const performTests = async (testObjects: object[], cmd: any) => {

const endTime = new Date().getTime();
const execTime = (endTime - startTime) / 1000;

if (error.isError === true) {
if (runTimes === 1) {
spinner.clear();
Expand All @@ -177,6 +176,10 @@ export const performTests = async (testObjects: object[], cmd: any) => {
}
} else {
spinner.fail(colorizeCustomRed(`Testing ${chalk.bold(colorizeCustomRed(requestName))} failed to validate. Retrying (${chalk.bold((runTimes - i).toString())})... (${chalk.bold(`${execTime.toString()}s`)}) \n${error.message}\n`))
// if the result should be logged
if (val.log === true || val.log == 'true' || printAll === true) {
console.log("Response: \n" + JSON.stringify(error.har, null, 2))
}
continue
}
}
Expand Down Expand Up @@ -205,6 +208,9 @@ export const performTests = async (testObjects: object[], cmd: any) => {
}
}
}
if (val.validate == null && val.maxRetries > 0) {
continue
}
if (toCurl === true) {
console.log(`\n${colorizeMain('Curl Equivalent: ')}${chalk.grey(error.curl)}\n`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ requests: # all test requests will be listed here
# log: true
validate:
- jsonpath: status
expect: 200
expect: 200
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ requests: # all test requests will be listed here
# log: true
validate:
- jsonpath: status
expect: 200
expect: 200
6 changes: 3 additions & 3 deletions tests/success/Methods/JsonPath/JsonPath.strest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
# Using http://jsonpath.com as object and simple testing
requests:
set_JsonPath:
set_Path:
request:
url: https://jsonplaceholder.typicode.com/posts
method: POST
Expand Down Expand Up @@ -31,13 +31,13 @@ requests:
expect: "0123-4567-8910"
- jsonpath: status
expect: 201
JsonPath:
validate_Path:
request:
url: https://postman-echo.com/get
method: GET
queryString:
- name: foo
value: <$ JsonPath("set_JsonPath.content.phoneNumbers[?(@.type == \"home\")].number") $>
value: <$ JsonPath("set_Path.content.phoneNumbers[?(@.type == \"home\")].number") $>
validate:
- jsonpath: content.args.foo
expect: 0123-4567-8910
8 changes: 8 additions & 0 deletions tests/success/other/repeat3.strest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
requests:
repeat3:
request:
url: https://postman-echo.com/time/now
method: GET
delay: 900
maxRetries: 3
12 changes: 12 additions & 0 deletions tests/success/validate/mimeType.strest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
requests:
mimeType:
request:
url: https://postman-echo.com/post
method: POST
postData:
text: foo
mimeType: application/xml
validate:
- jsonpath: content.headers['content-type']
expect: application/xml
14 changes: 14 additions & 0 deletions tests/success/validate/zero.strest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
requests:
zero:
request:
url: https://postman-echo.com/post
method: POST
postData:
text: "0"
mimeType: text/plain
validate:
- jsonpath: status
expect: 200
- jsonpath: content.data
expect: 0

0 comments on commit 0af282f

Please sign in to comment.