处理赛普拉斯URL重定向 [英] Handling Cypress url redirect
问题描述
我有一个赛普拉斯测试,该测试单击图像导致重定向到特定的url。然后,测试会检查URL中是否包含特定的字符串。
I have a Cypress test which clicks on an image causing a redirect to a specific url. The test then checks the url contains a specific string.
但是,单击此图像会导致测试停止/失败,并带有糟糕,没有要运行的测试。
However, clicking this image causes the tests to stop/fail with a "Whoops, there is no test to run." message when the redirect happens.
赛普拉斯测试非常简单:
The Cypress test is very simple:
/* global describe, it, cy */
import loadStory from '../../../config/cypress/helpers/loadStory'
const component = 'product-card'
const productCardImage = '[data-test=component-product-card_imageContainer]'
describe(`${component} component interaction tests`, () => {
it('clicking the image should open the products page', () => {
loadStory(component, 'Default')
cy.get(productCardImage).should('be.visible')
cy.get(productCardImage).click()
cy.url().should('contain', '/product')
})
})
我的测试在 http:// localhost:9002 $ c上运行$ c>,并且似乎在测试套件运行时重定向到
http:// localhost:9002 / product / productId
是导致Cypress崩溃/失败,而是Cypress崩溃的原因尝试转到 https:// localhost:9002 / __ /
My tests run on http://localhost:9002
and it seems that redirecting to http://localhost:9002/product/productId
while the test suit is running is what causes Cypress to crash/fail and instead Cypress tries to go to https://localhost:9002/__/
我想知道如何单击此图像并重定向到url,而不会在Cypress中造成崩溃/失败。
I am wondering how I can click this image and redirect to the url without causing this crash/fail in Cypress.
推荐答案
它们是 http
到 https $ c $的问题c>。
这篇关于处理赛普拉斯URL重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!