为什么在下面的赛普拉斯测试中response
不返回id
,console.log()
打印为'undefined'
describe('Hello', function() {
it.only('Hello', function() {
const getId = function() {
cy.request('GET', 'https://jsonplaceholder.typicode.com/posts/42')
.then((response) => {
//response.body is automatically serialized into JSON
return response.body.id
})
}
const user_Id = getId();
console.log("This is my request"+user_Id);
})
})