/dashboard. Which assertion correctly checks this using cy.url()?The should('include', '/dashboard') assertion checks if the URL string contains the substring /dashboard. The contain alias is not supported by Cypress assertions, have is invalid here, and equal checks for exact match, which is not what we want.
https://example.com/login. Which option is correct?The correct assertion to check exact equality is should('equal', expectedUrl). The alias eq is not supported by Cypress assertions, equals is invalid, and match expects a regex, not a string.
https://example.com/profile/settings, what will be the result of this test code?cy.url().should('include', '/profile').and('include', '/settings')
The and command chains multiple assertions on the same subject. Both include checks pass because the URL contains both /profile and /settings. So the test passes.
https://example.com/shop. What is wrong with it?cy.url().should('startWith', 'https://example.com/shop')
Cypress does not support startWith as an assertion keyword. To check if a string starts with a substring, you can use should('match', /^https:\/\/example\.com\/shop/) with a regex.
/product and a query parameter id with any value. Which approach is best to write a reliable test?Using a regex with should('match', regex) allows checking the URL pattern including dynamic query parameters reliably. Checking substrings separately may pass false positives, and exact equality with a fixed id fails if the id changes.