I am trying to preserve cookies in index.js file :
Cypress.Cookies.defaults({
preserve: ['session_id', 'remember_token'],
})
But I want to exclude few files such as login/authentication files from using the preserved cookies because I want to test real login here.
I see that cypress provides something like:
Cypress.Cookies.defaults({
preserve: (cookie) => {
// implement your own logic here
// if the function returns truthy
// then the cookie will not be cleared
// before each test runs
},
})
But I am not sure how to exclude a folder/files inside this. If someone has an idea kindly help. Or if there is any other better option to exclude files from using preserved cookies do let me know
I don't believe there is a way to exclude Cookies based on what spec file is running. Instead, you could clear them in the specs that you do not want values, and create a helper to check they are set in the specs.