Hi there,
I am trying to automate a simple test case for a project.
I have an endpoint that converts a Notion page using its id and some dynamic variables to html for a subsequent request using Gmail API.
I have created a json test file with the following structure:
[
{
"email_variables": [
{
"key": "",
"value": ""
}
],
"notion_id": "",
"email": "",
"full_name": "",
"job_title": "",
"phone": ""
}
]
My test aim at veryfing that the function is dynamically applying the correct email signature with a bunch of post script tests on the first request (inside request directly):
/*console.log(pm.request.body.raw);*/
pm.test("Response must be valid and have a body", () => {
pm.response.to.be.ok;
pm.response.to.be.json; // Fixed syntax
});
let responseData = pm.response.json();
pm.collectionVariables.set("email_object", JSON.stringify(responseData)); //set for the next request
pm.test('signature_exists', () => {
pm.expect(responseData.body).to.exist; // le champ existe
pm.expect(responseData.body).to.not.be.empty; // il n'est pas vide
});
[...]
This set up works well when running requests individually but I encounter an issue when using the “Run folder” option.
The email_variables
array is not properly mapped for each iteration. I struggle the find a way to either parse or do something with this property but I have been unsuccessful so far.
The request body for each iteration is not valid:
[
{
"variables": [object Object
],
"notion_template": "..."
}
]
How can I convert a complex object and map an array for each request inside the request body?
Thank you in advance