You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got my own, separate Cypress project set up that runs tests against the Cypress Real World App (great way to practise different Cypress commands and tests, thanks team!).
At the moment I am simply trying to save some time by avoiding logging in via the login form when doing UI / integration tests. The custom auth command logs the user in (200) and the connect.sid cookie is set (it is also present on the next request), but when I try to visit http://localhost:3000/transaction/new immediately afterwards I am still redirected to the login page (despite having a valid auth cookie).
Not sure what I'm missing? I'm posting this as a discussion because I assume this is down to me not fully understanding the auth mechanism(s) of the express/react Real World App. What else does the custom auth command need to do to make the Real World App recognise that a user is logged in?
// commands.js
// Authenticate via the API using a POST request
Cypress.Commands.add('auth', (uri, username, password) => {
cy.fixture('auth.json').then((authData) => {
uri = uri || `${Cypress.env("apiUrl")}/login`
username = username || authData.post.username
password = password || authData.post.password
return cy.request('POST', uri, {
username: username,
password: password,
type: authData.post.type
})
})
})
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've got my own, separate Cypress project set up that runs tests against the Cypress Real World App (great way to practise different Cypress commands and tests, thanks team!).
At the moment I am simply trying to save some time by avoiding logging in via the login form when doing UI / integration tests. The custom auth command logs the user in (200) and the
connect.sid
cookie is set (it is also present on the next request), but when I try to visithttp://localhost:3000/transaction/new
immediately afterwards I am still redirected to the login page (despite having a valid auth cookie).Not sure what I'm missing? I'm posting this as a discussion because I assume this is down to me not fully understanding the auth mechanism(s) of the express/react Real World App. What else does the custom
auth
command need to do to make the Real World App recognise that a user is logged in?Beta Was this translation helpful? Give feedback.
All reactions