我想在当前的赛普拉斯测试中包括对api的“麻烦的”调用。 我的测试将最终包括首先som GUI测试,然后是调用(我想从针对api的大摇大摆的测试中复制出来)。
这是我编写的代码:
context('test', () => {
it('test', () => {
cy
.request('POST','http://ddd/test/exportLogs/', '"caseNumber":
"3012728,2"')
.its('body')
.should('include', 'customerIdentifier')
})
})
赛普拉斯ui中的错误是
CypressError: cy.request() failed on:
http://ddd/test/exportLogs/
The response we received from your web server was:
> 415: Unsupported Media Type
This was considered a failure because the status code was not '2xx' or
'3xx'.
If you do not want status codes to cause failures pass the option:
'failOnStatusCode: false'
-----------------------------------------------------------
The request we sent was:
Method: POST
URL: http://ddd/test/exportLogs/
Headers: {
"user-agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Cypress/3.1.0 Chrome/59.0.3071.115 Electron/1.8.2
Safari/537.36",
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"content-length": 25
}
Body: "caseNumber": "3012728,2"
-----------------------------------------------------------
The response we got was:
Status: 415 - Unsupported Media Type
Headers: {
"accept": "application/octet-stream, text/plain, application/xml, text/xml,
application/x-www-form-urlencoded, application/*+xml, multipart/form-data,
application/json, application/*+json, */*",
"content-length": "0",
"date": "Thu, 30 Aug 2018 07:57:31 GMT",
"connection": "close"
}
Body:
有人在这里看到我在做什么错吗? 是否可以指定一些“媒体类型”来解决此错误?