I'm trying to run the original Joomla Cypress tests here:
https://github.com/joomla/joomla-cms/tree/5.0-dev/tests/System
After Joomla gets successfully installed I always get this message when the next test starts:
CypressError: This session already exists. You may not create a new session with a previously used identifier. If you want to create a new session with a different setup function, please call `cy.session()` with a unique identifier other than **["admin","adminadminadmin","back"]**.
https://on.cypress.io/session
at Context.session (http://127.0.0.1:8000/__cypress/runner/cypress_runner.js:133555:72)
at wrapped (http://127.0.0.1:8000/__cypress/runner/cypress_runner.js:138644:43)
From Your Spec Code:
at Context.eval(webpack:///./tests/System/support/commands.js:57:12)
I'm using the same Helper Functions Joomla uses for Backend Login:
https://github.com/joomla-projects/joomla-cypress
This is the command Joomla uses for picking up the session:
Cypress.Commands.overwrite('doAdministratorLogin', (originalFn, username, password, useSnapshot = true) => {
// Ensure there are valid credentials
const user = username ?? Cypress.env('username');
const pw = password ?? Cypress.env('password');
// Do normal login when no snapshot should be used
if (!useSnapshot) {
// Clear the session data
Cypress.session.clearAllSavedSessions();
// Call the normal function
return originalFn(user, pw);
}
// Do login through the session
return cy.session([user, pw, 'back'], () => originalFn(user, pw), { cacheAcrossSpecs: true });
});
So i minimized everything like seen here:
describe('First Admin Login', () => {
it('First Admin Login', () => {
cy.doAdministratorLogin('admin', 'adminadminadmin', false);
})
it('Second Admin Login (session based)', () => {
cy.doAdministratorLogin();
});
})
The second admin login always fails like described above.