Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.
Here’s an outline with best practices for making your inquiry.
My question:
I’m creating my first tests around a graphQL collection. I started by creating two simple tests to ensure that a query executed successfuly and did not contain an “errors” element.
I tested this against a single query by modifying the query parameters to generate an error and ran the two tests – I got a test failure as expected.
When I run the entire collection using these same two tests, that particular query passes even though it failed when tested manually.
Details (like screenshots):
Here’s the individual query, with query parameters. It runs fine with valid parameters:
query GET_CLIENT_NAMES($id: ID!, $asOfDate: ID!) {
data: GetClient(id: $id, asOfDate: $asOfDate) {
displayName
}
}
Query details changed for privacy
{
"id": "XXXX",
"asOfDate": 1653980400,
"portfolioId": "XXXX:1653980400"
}
I’ve modified the parameters so that they are invalid and will generate an error.
These are the two query tests:
pm.test("Ensure 200 status code", function() {
pm.response.to.have.status(200);
})
pm.test("Response does not contain errors response", function () {
pm.expect(pm.response.text()).to.not.include("errors");
});
And the second (errors) test fails as expected:
Sorry… I’m limited in the number of images I can include :=((
image|690x411
I’ve added those same tests to the collection:
I have no variables defined for the collection – they’re all set on the individual queries for the moment. When I run the collection, that query passes:
How I found the problem:
Just running some basic tests to make sure I understood how graphQL testing works in Postman.
I’ve already tried:
Searched for relevant answers here.
Tried changing variable values.