https://cypress.io logo
Hey all. I am trying to build a login command wi...
# e2e-testing
f
Hey all. I am trying to build a login command within my NuxtJS application using the Nuxt Auth module. The command looks like:
Copy code
js
Cypress.Commands.add('login', () => {
  const data = JSON.stringify({
    username: Cypress.env('TEST_USERNAME'),
    password: Cypress.env('TEST_USER_PASSWORD'),
  })
  cy.window().then((window) => {
    window.nuxtApp.$auth.loginWith('login', data)
  })
})
What I don't understand is this is giving me a
Xhr
request with
canceled: true
. I read that
canceled: true
occurs because I am attempting a URL change after calling my login command like:
Copy code
js
cy.login()
cy.visit('http://localhost:3000/settings/info')
Should I be waiting for the login command to finish? I tried adding an alias like:
Copy code
js
cy.login().as('login')
cy.wait('@login')
but Cypress didn't seem to like that...