如何替换或删除:“\n\t\t\t\t\t\t\t\t\t\t\t”和 html 文本中的任何白色 space In CYPRESS

How do I replace or remove: "\n\t\t\t\t\t\t\t\t\t\t\t" and any white space from the html text In CYPRESS

断言错误

25 | ReceiptPage.getPageIntro().should('have.text', this.data.receiptPageIntro)

预期 包含文本:“在本节中,设置了中继响应、静音 Post 和收据 Link 的设置。这些设置决定了收据显示以及交易数据如何传回商家",

但文本是:“\n\t\t\t\t\t\t\t\t\t\t\t 在本节中,设置了中继响应、静音 Post 和收据 Link 的设置。这些设置指示收据显示以及如何显示交易数据被传输回商家。\n\t\t\t\t\t\t\t\t\t\t"

您可以只使用 contains.text 来代替:

ReceiptPage.getPageIntro().should('contains.text', this.data.receiptPageIntro)

同样,你也可以使用include.text

ReceiptPage.getPageIntro().should('include.text', this.data.receiptPageIntro)