{"id":218,"date":"2015-11-16T09:00:00","date_gmt":"2015-11-16T00:00:00","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2015\/11\/16\/nock-with-mocha"},"modified":"2022-10-28T21:59:11","modified_gmt":"2022-10-28T12:59:11","slug":"nock-with-mocha","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2015\/11\/16\/nock-with-mocha\/","title":{"rendered":"Mocha\u3068Nock\u3067\u30e2\u30c3\u30af\u30b5\u30fc\u30d0\u30fc\u3092\u4f5c\u3063\u3066\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u30c6\u30b9\u30c8"},"content":{"rendered":"
\u6708\u306b1kg\u3072\u3088\u3053\u8c46\u3092\u98df\u3079\u308b\u5c0f\u98fc\u3067\u3059\u3002 nock<\/a><\/p>\n \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3068\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306eAPI\u3068\u306e\u901a\u4fe1\u3092\u30c6\u30b9\u30c8\u3057\u307e\u3059\u3002 \u4eca\u56de\u306f \u30c6\u30b9\u30c8\u306b\u7528\u3044\u305f\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u4e3b\u306b3\u3064\u3067\u3059\u3002<\/p>\n nock<\/a><\/p>\n Node.js\/\u30d6\u30e9\u30a6\u30b6\u5171\u7528\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3002 mocha<\/a><\/p>\n \u30c6\u30b9\u30c8\u5931\u6557\u6642\u306e\u8c4a\u5bcc\u306a\u60c5\u5831\u91cf\u3068\u30b7\u30f3\u30d7\u30eb\u306aAPI\u304c\u9b45\u529b\u306e\u30c6\u30b9\u30c8\u7d50\u679c\u691c\u8a3c\u30e9\u30a4\u30d6\u30e9\u30ea\u3002<\/p>\n power-assert<\/a><\/p>\n \u305d\u308c\u3067\u306f\u5b9f\u969b\u306b \u307e\u305a\u306f\u5404\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002
\n\u5148\u65e5\u5f53\u30d6\u30ed\u30b0\u3067\u5ca1\u672c\u304csinon.js\u3067XHR\u3092\u30ad\u30e3\u30c3\u30c1\u3057\u3066\u30e2\u30c3\u30af\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3059\u65b9\u6cd5<\/a>\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u3066\u3044\u307e\u3057\u305f\u3002
\n\u3061\u3087\u3046\u3069\u79c1\u3082\u5225\u306e\u6848\u4ef6\u3067API\u30b5\u30fc\u30d0\u30fc\u3078\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30c6\u30b9\u30c8\u3092\u5b9f\u88c5\u3057\u305f\u306e\u3067\u3059\u304c\u3001\u5ca1\u672c\u3068\u306f\u9055\u3063\u305f\u30a2\u30d7\u30ed\u30fc\u30c1\u3092\u63a1\u7528\u3057\u307e\u3057\u305f\u3002
\n\u672c\u7a3f\u3067\u306fNode.js<\/code>\u306e
http<\/code>\u30e2\u30b8\u30e5\u30fc\u30eb\u304b\u3089\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u30ad\u30e3\u30c3\u30c1\u3057\u3066\u30e2\u30c3\u30af\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3059
nock<\/code>\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n
\u76ee\u7684<\/h2>\n
\n\u5f0a\u793e\u3067\u306fflux<\/code>\u3092\u30d9\u30fc\u30b9\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u3053\u3068\u304c\u591a\u304f\u3001\u901a\u4fe1\u90e8\u5206\u306f
ActionCreators<\/code>\u30ec\u30a4\u30e4\u30fc\u306b\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059\u3002
\n\u305d\u306e\u305f\u3081XHR\/http\u30e2\u30b8\u30e5\u30fc\u30eb<\/code>\u3092\u5207\u308a\u66ff\u3048\u308b\u30e6\u30cb\u30d0\u30fc\u30b5\u30eb\u306a\u901a\u4fe1\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u7528\u3044\u3066\u3044\u308c\u3070\u3001\u6bd4\u8f03\u7684\u74b0\u5883\u3078\u306e\u4f9d\u5b58\u304c\u4f4e\u3044\u30c6\u30b9\u30c8\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n
mocha<\/code>\u3067\u8d70\u3063\u3066\u3044\u308b\u30c6\u30b9\u30c8\u74b0\u5883\u3067
nock<\/code>\u3092\u7528\u3044\u305f\u507d\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8a2d\u5b9a\u3057\u3066\u901a\u4fe1\u6a5f\u80fd\u306e\u30c6\u30b9\u30c8\u3092\u5b9f\u88c5\u3057\u307e\u3057\u305f\u3002<\/p>\n
\u5c0e\u5165<\/h2>\n
nock<\/h3>\n
http<\/code>\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u7528\u3044\u305f\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9014\u4e2d\u3067\u30ad\u30e3\u30c3\u30c1\u3057\u3066\u507d\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3059\u30e2\u30b8\u30e5\u30fc\u30eb\u3002<\/p>\n
mocha<\/h3>\n
mocha.conf.js<\/code>\u306e\u3088\u3046\u306a\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u5fc5\u8981\u3068\u3057\u306a\u3044\u306e\u3067\u3001\u624b\u8efd\u306b\u30c6\u30b9\u30c8\u304c\u59cb\u3081\u3089\u308c\u307e\u3059\u3002<\/p>\n
power-assert<\/h3>\n
\u9069\u7528<\/h2>\n
superagent<\/code>\u3092\u4f7f\u3063\u305f\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u30ad\u30e3\u30c3\u30c1\u3057\u3066\u507d\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n
\n\u203bespower-loader\/intelli-espower-loader<\/code>\u306f
power-assert<\/code>\u306e\u88dc\u52a9\u7684\u306a\u30e2\u30b8\u30e5\u30fc\u30eb\u3060\u3068\u601d\u3063\u3066\u304f\u3060\u3055\u3044\u3002
\n\u306a\u305c\u5fc5\u8981\u306a\u306e\u304b\u306f\u3053\u306e\u8a18\u4e8b<\/a>\u3092\u53c2\u7167\u3002<\/p>\nnpm install --save-dev mocha power-assert espower-loader intelli-espower-loader nock superagent<\/code><\/pre>\n