I have declaration step by javascript like this
When('get schedule and state from {string} of batch {string}', function (awsProfile, batchName) {
batchName = getVal(batchName, this)
awsProfile = getVal(awsProfile, this)
const args = ['events', 'describe-rule', '--profile', awsProfile, '--name', batchName]
const res = runAWS(args)
return res
})
The res is return result like this
......{
stdout: '{rn' +
' "Name": "time",rn' +
' "ScheduleExpression": "12:00",rn' +
' "State": "VN",rn' '}rn'
status: 0
}
and then I just like to make like a json not have include “nr” or “‘”. I put more step is
When('get schedule and state from {string} of batch {string}', function (awsProfile, batchName) {
batchName = getVal(batchName, this)
awsProfile = getVal(awsProfile, this)
const args = ['events', 'describe-rule', '--profile', awsProfile, '--name', batchName]
const res = runAWS(args)
const getJson = JSON.parse(res.stdout) //NEW LINE
return res
})
And the result is
......
{
Name: 'time',
ScheduleExpression: '12:00',
State: 'VN'
}
...
It’s not like a json what I need, as I need is:
{
"Name": "time",
"ScheduleExpression": "12:00",
"State": "VN"
}
How can I make change like that, and set assign a name for that json like this:
info {
"Name": "time",
"ScheduleExpression": "12:00",
"State": "VN"
}
Please help me, I need to get this result and save it in a file.
this function I make in a nother file, and called by Cucumber.
Thank you so much