cypress-saveLogAndFilter: post logine api done.
This commit is contained in:
@@ -10,7 +10,24 @@
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
||||
const loginApiUrl = Cypress.env('loginApiUrl');
|
||||
Cypress.Commands.add('login', () => {
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: loginApiUrl,
|
||||
form: true,
|
||||
body: {
|
||||
username: Cypress.env('user').username,
|
||||
password: Cypress.env('user').password
|
||||
}
|
||||
}).then(response => {
|
||||
console.log(response);
|
||||
cy.log(response)
|
||||
const token = response.body.access_token;
|
||||
cy.setCookie('luciaToken', token);
|
||||
})
|
||||
});
|
||||
// 呼叫方式: cy.login()
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
|
||||
Reference in New Issue
Block a user