Cypress.Cookies.preserveOnce f
How To Preserve Cookie Once In Cypress v10 InstallCypress.Cookies.preserveOnce for Cypress v10
# if using NPM $ npm i -D cypress-v10-preserve-cookie # if using Yarn $ yarn add -D cypress-v10-preserve-cookie
Import this module from your spec file or from your support file
import 'cypress-v10-preserve-cookie'
This module adds a custom command cy.preserveCookieOnce
// login sets the cookie like "connect.session" for example before(loginSomehow) beforeEach(() => { // equivalent to cy.preserveCookieOnce('connect.session') cy.preserveCookieOnce('connect.session') }) it('is logged in', () => { ... }) it('is still logged in', () => { ... }) Multiple cookies
You can pass multiple cookie names
cy.preserveCookieOnce( 'connect.session', 'refresh_token', 'access_token', ) // equivalent to cy.preserveCookieOnce('connect.session') cy.preserveCookieOnce('refresh_token') cy.preserveCookieOnce('access_token') Types
Included in src/index.d.ts
DebuggingThis module uses debug module to output verbose browser console messages when needed. To turn the logging on, open the browser's DevTools console and set the local storage entry:
localStorage.debug = 'cypress-v10-preserve-cookie'
If you re-run the tests, you should see the messages appear in the console.
If you need more control over storing/restoring cookies/users/any other data, check out my plugin cypress-data-session.
Small printAuthor: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2022
@bahmutov glebbahmutov.com blog videos presentations cypress.tips Cypress Tips & Tricks Newsletter my Cypress coursesLicense: MIT - do anything with the code, but don't blame me if it does not work.
Support: if you find any problems with this module, email / tweet / open issue on Github
版权声明:
1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。2、网站不提供资料下载,如需下载请到原作者页面进行下载。