我正在测试剧作家中的两个不同的文本内容。
一旦用户选择了特定选项,我就必须返回主页并检查文本内容。 我已经有了针对特定选项的 if 语句,但我需要帮助来断言对文本内容的期望。 这是我的测试:
async verifyParticipantEligibility() {
expect (await this.participantStatus.textContent()).toBe('Screened - Ineligible')
expect (await this.participantStatus.textContent()).toBe('Can be re-screened')
}
我在下面尝试过:
async verifyParticipantEligibility() {
// requires if statement - using above.
expect (await this.participantStatus.textContent()).toBe('Screened - Ineligible')
expect (await this.participantStatus.textContent()).toBe('Can be re-screened')
}
这自然是寻找第一个,如何在剧作家中断言两个不同的文本内容?
您可以通过正则表达式检查一个字符串或另一个字符串来解决这个问题:
expect (await this.participantStatus.textContent())
.toHaveText(/Screened - Ineligible|Can be re-screened/)