如何使用IT测试和之前的ViveWports迭代数组
我遇到了视口问题,但我还没有找到解决方案。
describe('Tests', function () {
beforeEach(function () {
});
viewports.forEach((viewport) => {
it.only(`Test: ${viewport}`, function () {
cy.viewportAdjust(viewport);
})})})
我在测试中使用了cy.viewportadjust(fiewport);
它有效,但是我希望将cy.viewportadjust(viewport);
移动到之前部分,但对于测试,它使用了fiewportsarray的最后值
I run into issue with viewport issue and I didn't find the solution yet.
describe('Tests', function () {
beforeEach(function () {
});
viewports.forEach((viewport) => {
it.only(`Test: ${viewport}`, function () {
cy.viewportAdjust(viewport);
})})})
I used cy.viewportAdjust(viewport);
in my test and it works, however I wish to move cy.viewportAdjust(viewport);
to beforeEach
section but for tests it uses last value of viewportsArray
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不完全确定
cy.viewportadjust()
是什么,因为这看起来是自定义功能。如果该函数只需调用cy.viewport()
或更新视口,则以下功能将起作用。此外,由于不知道viewport
中的值是什么,我不能给出一个完整的答案,但是总体想法是您可以在> IT中传递evientportwidth或ViewPortheight( )
块。I'm not entirely sure what
cy.viewportAdjust()
does, as that looks to be a custom function. If the function simply callscy.viewport()
or updates the viewport, the following will work. Additionally, with not knowing what the values inviewport
are, I can't give an exact complete answer, but the general idea is that you can pass in your viewportWidth or viewportHeight in theit()
block.我将准确地回答这个问题。但是我不建议这样做,尽管没有看到您要做的一切,但我对此声明没有100%的信心。
相反,我建议您删除前面的块并将您的代码放在IT块中。
Im going to answer this question exactly how you asked. But I would not suggest doing it this way though without seeing everything that you are trying to do I don't have 100% confidence in this statement.
I would instead suggest removing the beforeEach block and putting your code within the it block.