Vue 剧作家测试来检查 url

问题描述 投票:0回答:1

我有一个剧作家测试,我想检查我的页面上是否存在两个按钮的 URL。我不确定下面将在哪里创建存根和我的测试之间的链接:


test('displays support page', async ({ page, server  }) => {

  const support = {
    email: "[email protected]",
    phone: "+48 20 1234 5678",
    learning_url: "https://learning.com/test",
    portal_url: "https://portal.com/test"
  }

  await server.create('support', support)

  const eLearningButton = page.getByRole('button').and(page.getByTitle(enUS.pages.support.button));
  expect(eLearningButton).toContain('https://learning.com/test');

  const faqButton = page.getByRole('button').and(page.getByTitle(enUS.pages.portal.button));
  expect(faqButton).toContain('https://portal.com/test');
})

我尝试运行测试但失败了

vue.js e2e-testing playwright
1个回答
0
投票

如果按钮具有

:href
属性。你可以这样做:

await expect(eLearningButton).toHaveAttribute(':href', 'https://learning.com/test');
© www.soinside.com 2019 - 2024. All rights reserved.