更新时间:2023-11-27 23:39:34
这是赛普拉斯的预期行为.我相信您必须在每个it()
/context()
This is expected behavior in Cypress. I believe you have to preserve the cookies post every it()
/ context()
,
beforeEach('Preserve the cookies to persist the state', () => {
Cypress.Cookies.preserveOnce('sessionid', 'csrftoken')
})
在上面的脚本中,sessionid
和csrftoken
是我希望在每次测试后保留/保留的令牌名称.
In the above script sessionid
and csrftoken
are the token names which I want to preserve/ retain after each test.
另一种方法是将要保留的cookie令牌列入白名单,
An alternative is to whitelist the cookie tokens which you want to preserve,
Cypress.Cookies.defaults({whitelist: 'sessionid'});