Mar*_*rga 6 javascript axios moxios
是否可以使用moxios模拟对POST请求的回复,该请求不仅可以通过URL匹配,还可以通过POST正文匹配?事后检查身体对我也有用.
这就是我现在正在做的事情.据我所知,没有方法特定的存根方法:
describe('createCode', function () {
it('should create new code', function () {
moxios.stubRequest(process.env.API_URL + '/games/GM01/codes', {
status: 200
})
})
})
Run Code Online (Sandbox Code Playgroud)
有一种方法可以使用moxios检查最后一个axios请求:
let request = moxios.requests.mostRecent()
expect(request.config.method).to.equal('post')
expect(JSON.parse(request.config.data)).to.deep.equal(code)
Run Code Online (Sandbox Code Playgroud)
配置对象是在axios中传递的,data是请求的主体.
| 归档时间: |
|
| 查看次数: |
3540 次 |
| 最近记录: |