Created
May 24, 2018 02:20
-
-
Save kjirou/1f2b2ddc941cbc63061171f64798bee8 to your computer and use it in GitHub Desktop.
nockサンプルコードの供養
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @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