Testing 如何使用";。包括「;断言以匹配其中一个值
根据我的应用程序,单击其中一个链接可以打开两个URL中的一个URL 例如:单击Link-X,它可以打开以下URL之一: 或 我必须为此编写一个Testing 如何使用";。包括「;断言以匹配其中一个值,testing,automated-tests,e2e-testing,assertion,testcafe,Testing,Automated Tests,E2e Testing,Assertion,Testcafe,根据我的应用程序,单击其中一个链接可以打开两个URL中的一个URL 例如:单击Link-X,它可以打开以下URL之一: 或 我必须为此编写一个。其中包含类似以下内容的断言: expect(currentUrl).contains(value1 or value2) 根据TestCafe文档,contains不支持正则表达式,我不想使用Match,因为我必须在那里传递不完整的URL 请让我知道如何做到这一点。 谢谢。我已经用下面的匹配断言解决了这个问题,但是如果能用contain断言也能解决这个
。其中包含类似以下内容的断言:
expect(currentUrl).contains(value1 or value2)
根据TestCafe文档,contains不支持正则表达式,我不想使用Match,因为我必须在那里传递不完整的URL
请让我知道如何做到这一点。
谢谢。我已经用下面的匹配断言解决了这个问题,但是如果能用contain断言也能解决这个问题,那就太好了
expect(currentUrl).match(/value1|value2$/)
检查以下“当前位置”示例测试:
import { ClientFunction } from 'testcafe';
fixture `Fixture`
.page `https://google.com`;
test('Check location', async t => {
// Some actions and assertions...
await t
.navigateTo(/*...*/)
.click(/*...*/);
// Then check our location
const getLocation = ClientFunction(() => document.location.href);
const location = await getLocation();
await t
.expect(location.includes('microsoft') || location.includes('google')).ok();
});