How to store an array of json objects in a data template? #363
-
My data template structure is stash.addDataTemplate({
connectionSecrets: [
{
"id": 589,
"createdAt": "xxx",
"updatedAt":"xxx"
},
{
"id": 590,
"createdAt": "xxx",
"updatedAt":"xxx"
}
]
}); I am using it as .expectJsonLike({'@DATA:TEMPLATE@': 'connectionSecrets'}); And the api response body looks like [
{
"id": 589,
"createdAt": "xxx",
"updatedAt":"xxx"
},
{
"id": 590,
"createdAt": "xxx",
"updatedAt":"xxx"
}
] How can this be resolved? And while digging further i found this |
Beta Was this translation helpful? Give feedback.
Answered by
ASaiAnudeep
Jun 23, 2024
Replies: 1 comment 2 replies
-
Hello @binduHR , have you loaded the data templates into the context of your test execution? For example, if the data templates are declared in a different file, we need to load them before the start of the test execution. // template.js
stash.addDataTemplate({
connectionSecrets: [
{
"id": 589,
"createdAt": "xxx",
"updatedAt":"xxx"
},
{
"id": 590,
"createdAt": "xxx",
"updatedAt":"xxx"
}
]
}); // load template file
require('template.js')
await spec()
.expectJsonLike('connectionSecrets') |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
binduHR
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @binduHR , have you loaded the data templates into the context of your test execution?
For example, if the data templates are declared in a different file, we need to load them before the start of the test execution.