Unit test: How to mock axios in react?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm testing a axios inside the getArticlesFromDatabase . Seems like I'm doing wrong, cause console shows following message: (node:36919) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): here is reject fail: (node:36919) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. How to fix it? csrfData.js import axios from 'axios'; var getArticlesFromDatabase = new Promise(function(resolve,