

在附件中,我放了来自同一个测试用例的屏幕截图,它们之间有几秒钟的差异。
我想知道为什么每次尝试相同的测试用例结果都是 4xx、5xx、2xx?我怎样才能避免它?会不会和等待有关?
PS 我和 DevOps 团队谈过,他们说环境是稳定的。
Spec.js
it.only("buy a fix priced vehicle", () => {
const minPrice = 26350;
//const maxPrice = 1000000;
//const offerAmount = Math.floor(Math.random() * maxval) + minval;
const vehicleIdBuyNow = "30f269ac675813a68885ce336971d897";
const platformIdBuyNow = "yyyy";
const platformUserIdBuyNow = 0;
[![enter image description here][1]][1]
cy.request({
method: "POST",
url: "xxxxxx",
headers: {
Authorization:
"tttttt",
"content-type": "application/json",
},
body: {
id: vehicleIdBuyNow,
bid: minPrice,
auctionPlatformId: platformIdBuyNow,
auctionPlatformUserId: platformUserIdBuyNow,
},
failOnStatusCode: false,
}).then((res) => {
cy.wait(2000)
// Assertion for one by one
//cy.log(res)
//if ( res.status==404 || res.status==400 || res.status==500 || res.status==503) {
if ( res.status!=200) {
cy.log(JSON.stringify(res))
} else {
expect(res.body.id).to.eq(
vehicleIdBuyNow
);
expect(res.body.auctionStatus).contains("finished");
expect(res.body.price).to.be.equal(minPrice);
expect(res.body.winningBidPlatformId).contains(platformIdBuyNow);
expect(true).to.be.true;
expect(false).to.be.false;
//Assertion in one time
// for (const index of res.body.suggestedPrices) {
// expect(res.body.suggestedPrices[index].amount).to.be.within(
// minPrice,
// maxPrice
// );
// }
assert.isNotNull(res.amount, "is not null");
assert.isNotNull(res.body.id, "is not null");
assert.isNotNull(res.body.createdAt, "is not null");
}
})