赛普拉斯测试超时

时间:2020-06-21 14:34:12

标签: url redirect cypress

我的url缩短应用程序支持链接到其他短链接的短链接。换句话说,我已有一个指向该亚马逊链接的短链接http:// localhost:8080 / dishpods。

当我创建一个指向http:// localhost:8080 / dishpods的短链接时,浏览器会跟随最后的亚马逊链接正常运行。但是,尽管我将followRedirect:true设置为cypress,赛普拉斯测试也只是挂在那里。如何使测试捕获我的应用程序的行为并停止挂起?

应用示例: enter image description here enter image description here enter image description here enter image description here

测试代码:

  it('Creates a Redirect from a Redirect', function () {
    // Cypress does not allow redirect to a redirect

    const dishpodsShortUrl = 'http://localhost:8080/f/dishpods'
    const originalAmazonLink = "https://www.amazon.com/gp/product/B07CTQ8THP/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1";
    cy.visit("/api/v1/create_short_url") // To do - aria tags to identify
    cy.get('input[name="longUrl"]').type(dishpodsShortUrl)
    cy.get('form').submit()
    cy.get('body').length > 0
    cy.location().should((loc) => {
      expect(loc.host).to.eq('localhost:8080')
      expect(loc.href).to.eq('http://localhost:8080/api/v1/create_short_url')
    })

    cy.get('body')
            .invoke('text').then((urlToFollow) => {
      cy.request({
        url: '/f/' + urlToFollow,
        followRedirect: true
      }).then((resp) => {
        expect(resp.status).to.eq(200)
        expect(resp.body).to.eq(dishpodsShortUrl)
      })
    })
  });

0 个答案:

没有答案