我想打從我code.test.js的愛可信請求文件的位置:如何從玩笑測試頁打Axios公司要求
import axios from 'axios'
import sinon from 'sinon';
describe('get-data',() => {
let data = {start_date:"2017-06-30",end_date:"2017-07-07",graph:"all"}
let sandbox;
let server;
beforeEach(() => {
sandbox = sinon.sandbox.create();
server = sandbox.useFakeServer();
});
afterEach(() => {
server.restore();
sandbox.restore();
});
it('should display a blankslate', (done) => {
axios.get('/api/get/data?data='+JSON.stringify(data))
.then((response.data) => {
console.log(response)
/*expect($('#users').innerHTML)
.to.equal('The list is empty.')*/ })
.then(done, done);
setTimeout(() => server.respond([200,
{ 'Content-Type': 'application/json' },
'[]']), 0);
});
})
,但我得到的console.log(response.data)爲未定義。
任何人都可以告訴我如何獲得數據在這裏迴應?
考慮檢查出[諾克](https://github.com/node-nock/nock) –