Skip to content

Instantly share code, notes, and snippets.

@kjirou
Created May 24, 2018 02:20
Show Gist options
  • Save kjirou/1f2b2ddc941cbc63061171f64798bee8 to your computer and use it in GitHub Desktop.
Save kjirou/1f2b2ddc941cbc63061171f64798bee8 to your computer and use it in GitHub Desktop.
nockサンプルコードの供養
// @flow
import axios from 'axios';
import {describe, it, beforeEach, afterEach} from 'mocha';
import nock from 'nock';
describe('nockのテスト', function() {
it('testtest', function() {
const scope =
nock('http://localhost')
//nock('https://localhost')
//nock('https://example.com')
//.persist()
.get('/foo')
//.times(2)
.reply(200, 'FOO!')
;
return Promise.resolve()
.then(() => {
return axios.get('http://localhost/foo');
})
.then((r) => {
console.log(r.data);
})
//.then(() => {
// return axios.get('http://localhost/foo');
//})
//.then((r) => {
// console.log(r.data);
//})
;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment