I am validating the cookie in my below 'login' Cypress test, but cypress throws following error :
TypeError: cy.chain is not a function
Clearly imported the following under '../support/index.js'
Can someone please advise why the error is throwing
import './commands'
cypress test:
describe("Login test validate cookie", () => {
it.only('Verify the cookies test for login', function() {
cy
.login(Cypress.env('email'), Cypress.env('password'))
cy
.getCookie('csrftoken')
.then((csrftoken) => {
console.log(csrftoken)
})
})
Following is my 'login' method/function ../support/commands.js
Cypress.Commands.add('login', (email, password) => {
return cy.chain().request({
method: 'POST',
form: true,
url: '${cypress.env("test_server")}',
body: '{"email", "password"}',
})
});
The below details are provided in 'cypress.env.json' file
{
"email": "[email protected]",
"password": "test1234"
}