Unescape JSON 要断言的数据值

Unescape JSON data values to assert

在使用数据驱动文件时,我将 json 文件设置为包含转义字符

 {
...
        "emailbodyHTML":"Hi [[Contact First Name]],\r\n\r\nToday is a nice day.\r\n\r\nThanks!",

...
    },

在我的测试中

dataSet.forEach(userdata => {
  test(`Enter '${userdata.testcasename}'`, async t => {  
....

     await t.expect(messagingDetailsPage.emailBodyHTML.value).eql(userdata.emailbodyHTML,"Email Body in HTML Match Not Found")

...

}

我假设断言有效 - 我必须执行某种反向转义?任何指示都会有所帮助。

我意识到 JSON 测试文件不能包含大写字符,因此失败了。一旦我把它改成这样:

"emailbodyhtml": "<p>Hi [[Contact First Name]],</p><p>Today could be a coincidental peak day and there is a high probability a Demand Response event will be scheduled this afternoon.</p><p>Thanks!</p>",

我的测试

await t.expect(messagingDetailsPage.emailBodyHTML.innerText).eql(userdata.emailbodyhtml,"Email Body in HTML Match Not Found")

问题已解决。