Bird
0
0

Which of the following is the correct syntax to perform a POST login request using cy.request in Cypress?

easy📝 Syntax Q12 of 15
Cypress - Authentication and Sessions
Which of the following is the correct syntax to perform a POST login request using cy.request in Cypress?
Acy.request('GET', '/login', { username: 'user', password: 'pass' })
Bcy.request('/login', 'POST', { username: 'user', password: 'pass' })
Ccy.request({ url: '/login', method: 'GET', body: { username: 'user', password: 'pass' } })
Dcy.request('POST', '/login', { username: 'user', password: 'pass' })
Step-by-Step Solution
Solution:
  1. Step 1: Recall cy.request method signature

    The correct order is cy.request(method, url, body) for POST requests.
  2. Step 2: Check each option

    cy.request('POST', '/login', { username: 'user', password: 'pass' }) matches the correct syntax with method 'POST', URL '/login', and body object.
  3. Final Answer:

    cy.request('POST', '/login', { username: 'user', password: 'pass' }) -> Option D
  4. Quick Check:

    Method first, then URL, then body [OK]
Quick Trick: Remember: method, URL, then body in cy.request [OK]
Common Mistakes:
  • Swapping method and URL order
  • Using GET instead of POST for login
  • Passing body with GET method

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes