-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP requests and response body validation don't work with non-object content #262
Comments
Here is an example request that causes issues. 1. Create a request with the GitHub Commits APIThe following request gets the last two commits containing
2. Analyze the response
The JSON response for this API endpoint is always contained in a top-level array. Let's try to get a value. 3a. Create a test with the GitHub Commits API.We try to test the "sha" value of the first entry. {
"tests": [
{
"id": "check-file-sha",
"description": "Check file SHA",
"steps": [
{
"action": "httpRequest",
"url": "https://api.github.com/repos/doc-detective/doc-detective-core/commits",
"method": "get",
"requestHeaders": {
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28"
},
"requestParams": {
"path": "src/config.js",
"per_page": "2"
},
"responseData": {
"sha": "3b40e4448e8db95a1f84f960264a4d0586bb1aff"
},
"statusCodes": [200]
}
]
}
]
} 3b. Test failureThe test fails with an error because the top-level data structure is an array that doesn't contain a "sha" key: "result": "FAIL",
"resultDescription": "Returned 200. The 'sha' key did't exist in returned JSON.", 4a. Create a second test with an array objectTake the previous test, and encapsulate "responseData": [{
"sha": "3b40e4448e8db95a1f84f960264a4d0586bb1aff"
}], 4b. Test 2The test fails because Doc Detective thinks there are no tests. {
"summary": {
"specs": {
"pass": 0,
"fail": 0,
"warning": 0,
"skipped": 0
},
"tests": {
"pass": 0,
"fail": 0,
"warning": 0,
"skipped": 0
},
"contexts": {
"pass": 0,
"fail": 0,
"warning": 0,
"skipped": 0
},
"steps": {
"pass": 0,
"fail": 0,
"warning": 0,
"skipped": 0
}
},
"specs": []
} ThoughtsBecause It would be useful to accept special syntax to test a specific key in the response. |
Original report
If the request body is something other than a JSON object (even just an array), the test refuses to run.
If a response body is something other than a JSON object (even just an array), response validation fails.
The text was updated successfully, but these errors were encountered: