javascript - 如何使用 intern/web 驱动程序等待所有重定向完成?

标签 javascript node.js intern leadfoot

我正在尝试测试应用程序是否将用户重定向到经过身份验证的路由,因为他们不是管理员。

但我需要一种方法来等待所有重定向完成,然后再调用 getCurrentUrl()

    it('should not allow regular user access', async (test) => {
  await test.remote
      .then(e2e.impersonate('test@test.com'))
      .get('/protected-route')
      //.waitForAllRedirects()
      .getCurrentUrl()
      .then(url => {
        console.log('url', url);
        expect(url.indexOf('/landing-page')).not.toBe(-1);
        return true;
      });
});

最佳答案

最简单的做法可能是查找应位于非 protected 页面而不是 protected 页面上的内容。找到预期的内容后,请检查 URL 以验证您是否位于应在的位置。

it('should not allow regular user access', test => {
  return test.remote
    .then(e2e.impersonate('test@test.com'))
    .get('/protected-route')
    .findByCssSelector('.something.that.should.be.visible')
    .getCurrentUrl()
    .then(url => {
      console.log('url', url);
      expect(url.indexOf('/landing-page')).not.toBe(-1);
      return true;
    });
});

关于javascript - 如何使用 intern/web 驱动程序等待所有重定向完成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54206027/

相关文章:

javascript - d3js 弧高补间

javascript - 无法使用 Express.js 实现 CORS

node.js - Microsoft Botframework Prompts.choice 未获得验证响应

Selenium 测试理解

intern - 如何使用 Intern 对非 AMD JavaScript 文件进行单元测试?

javascript - Dojo 版本和 Intern 兼容性

javascript - 隐藏下拉菜单

javascript - 如何从 Windows Phone 的 HTML 或 Javascript 访问图像文件

javascript - 如何多次运行javascript函数直到满足if条件

node.js - 如何为 socket io 和 graphql 建立连接?