我正在尝试使用jest(集成测试)在基于反应本机的应用程序中测试apiwrapper.当我在iOs模拟器中运行时,一切运行正常,但它不会正确运行我的开玩笑测试 - 我总是得到:
ReferenceError: XMLHttpRequest is not defined
Run Code Online (Sandbox Code Playgroud)
当我尝试使用我的api包装器运行测试时,例如:
it('Login successful with correct data', () => {
let api = Api.getInstance();
return api.login("test", "testpass")
.then(result => expect(result).toEqual('login_successful'));
});
Run Code Online (Sandbox Code Playgroud)
我试图在这里测试的api类确实使用了fetch api(不是vanilla xhr).我假设它的某些东西与试图嘲笑某些东西有关,但还没有找到让它工作的方法.
提前致谢.
这与此问题有些相关:如何正确存储时间戳(自1970年以来的ms)
有没有办法输入一个AnyObject到Int64?我通过JSON接收到一个巨大的数字这个号码作为"AnyObject"到达我的班级 - 我怎么能把它转换为Int64-xcode只是说它不可能.
今天我更新到新发布的xCode 6 GM.当我尝试构建我的应用程序时,我得到一个编译器错误,说我的一个View控制器处理表"不符合协议UITableViewDataSource".之前一切正常(使用xCode 6 Beta 5)
根据文档,协议需要2种方法:
- tableView:cellForRowAtIndexPath:必需的方法
- tableView:numberOfRowsInSection:必需的方法
它们都实现了:
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return feed!.count
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
println("HashtagDetailViewController: tableView - cellForRowAtIndexPath called")
let cell = tableView.dequeueReusableCellWithIdentifier("postCell", forIndexPath: indexPath) as PostTableCell
cell.loadItem(feed!.toArray()[indexPath.row])
return cell
}
Run Code Online (Sandbox Code Playgroud)
我错过了什么?是否有一个新的必需方法不在文档中?谢谢你的帮助