我有一个端点,我出价/要求一定数量的车辆,然后在响应主体,我没有看到这个特定的数额,我只能看到之前的投标金额。但是我可以在不同的端点中得到投标金额的列表。因此,基本上我从一个端点请求,并验证不同读取拍卖端点的响应。我不知道如何维护API测试的逻辑。你能告诉我吗?谢谢。
第一次请求
it('bidding in external API', () => {
cy.request({
'method': 'POST',
'url': `${Cypress.env('ampApiPrefixForExternalEndpoints')}/bid`,
'headers': {
'Authorization': Cypress.env('externalToken'),
'content-type': Cypress.env('contentType'),
},
'body': {
'id': 'bbbbbb',
'bid': 42550,
'auctionPlatformId': 'xxxx',
'auctionPlatformUserId': 'aaaaa',
},
'failOnStatusCode': false,
}).then((res) => {
cy.log(JSON.stringify(res));
expect(res.status).to.eq(200);
})
});读取拍卖端点的响应.
Received response (200):
{
"data": {
"auctions": [
{
"additionalCosts": xxx,
"auctionCountryIso": "zxxc",
"ahId": "12324",
"auctionEndDatetime": "2022-03-20T06:03:47.394Z",
"auctionStartDatetime": "2022-03-14T06:03:47.394Z",
"auctionStatus": "ongoing",
"auctionType": "type",
"damageStatus": "normal",
"bidStep": asddf,
"bids": [
{
"amount": 29650,
"createdDatetime": "2022-03-15T05:56:47.394Z",
"externalData": [],
"isMaxBid": false,
"status": "accepted"
},
{
"amount": 29750,
"createdDatetime": "2022-03-15T05:57:47.394Z",
"externalData": [],
"isMaxBid": false,
"status": "accepted"
},
{
"amount": 29850,
"createdDatetime": "2022-03-15T05:58:47.394Z",
"externalData": [],
"isMaxBid": false,
"status": "accepted"
},
{
"amount": 29950,
"createdDatetime": "2022-03-15T05:59:47.394Z",
"externalData": [],
"isMaxBid": false,
"status": "accepted"
},
{
"amount": 30050,
"createdDatetime": "2022-03-15T06:00:47.395Z",
"externalData": [],
"isMaxBid": false,
"status": "accepted"
},
{
"amount": 30150,
"createdDatetime": "2022-03-15T06:01:47.395Z",
"externalData": [],
"isMaxBid": false,
"status": "accepted"
},
{
"amount": 30250,
"createdDatetime": "2022-03-15T06:02:47.395Z",
"externalData": [],
"isMaxBid": false,
"status": "accepted"
},
{
"amount": 44650,
"auctionPlatformId": "sdrwd",
"auctionPlatformUserId": "094c5519-bcaf-4100-8a40-904e04a7ecff",
"createdDatetime": "2022-03-15T14:34:54.432Z",
"externalData": {
"request_id": "saddsddse"
},
"isMaxBid": false,
"status": "accepted"
},
{
"amount": 44750,
"auctionPlatformId": "rwffffc",
"auctionPlatformUserId": "094c5519-bcaf-4100-8a40-904e04a7ecff",
"createdDatetime": "2022-03-15T14:35:11.596Z",
"externalData": {
"request_id": "adfds"
},
"isMaxBid": false,
"status": "accepted"
}
],发布于 2022-03-16 11:10:33
如果要按顺序命中两个端点,请使用.then()链接第二个端点。
cy.request({
'method': 'POST',
'url': `${Cypress.env('ampApiPrefixForExternalEndpoints')}/bid`,
...
}).then((res) => {
// verify 1st endpoint
expect(res.status).to.eq(200);
}).then(() => {
// ensure sequential calling
cy.request({
'method': 'GET',
'url': `${Cypress.env('ampApiPrefixForExternalEndpoints')}/read`,
...
}).then((res) => {
// verify 2nd endpoint
expect(res.status).to.eq(200);
...
})
})https://stackoverflow.com/questions/71495926
复制相似问题