小编dwi*_*ilt的帖子

Angular 2单元测试数据从父组件传递到子组件

我有一个问题,我看到(很少)测试从父组件传递到子组件的数据的方法.目前,在Angular2文档中,他们通过检查子组件的dom值来测试是否已将数据从父组件传递给子组件.我对这种方法的问题在于它强制父类的规范知道子组件的html结构.父组件的工作就是将数据传递给子组件.一个例子...

我有一个故事组件如下:

'use strict';

import {Component, OnInit, Input} from '@angular/core';
import {StoryService} from '../../services/story.service';
import {StoryModel} from '../../models/story-model';
import {AlbumCover} from './album-cover/album-cover';
import {Author} from "./author/author";
import {StoryDuration} from "./story-duration/story-duration";

@Component({
    selector: 'story',
    templateUrl: 'build/components/story/story.html',
    providers: [StoryService],
    directives: [AlbumCover, Author, StoryDuration]
})

export class Story implements OnInit {
    @Input('id') id:number;
    public story:StoryModel;

    constructor(private storyService:StoryService) {}

    ngOnInit() {
        this.getStory();
    }

    private getStory() {
        this.storyService.getStory(this.id).subscribe(story => this.story = story);
    }
}
Run Code Online (Sandbox Code Playgroud)

注意它在装饰器AlbumCover中的 …

components unit-testing angular

6
推荐指数
1
解决办法
4169
查看次数

React Native:EXC_BAD_ACCESS·尝试取消引用垃圾指针

在过去的几个月中,我们一直在我们的应用程序中随机出现这些错误,这些错误显示在Bugsnag中。它们肯定会导致崩溃,因为我们的团队内部成员已经报告了崩溃,但随后无法重现它们。这是完整的痕迹:

EXC_BAD_ACCESS Attempted to dereference garbage pointer 0x167f4beb8. 
/usr/lib/libobjc.A.dylib objc_msgSend
Frameworks/Foundation.framework/Foundation -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:usingBlock:]
Frameworks/Foundation.framework/Foundation -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:]
Frameworks/Foundation.framework/Foundation -[NSOperationQueue setMaxConcurrentOperationCount:]
GreatJonesStreet-Prod mh_execute_header
GreatJonesStreet-Prod mh_execute_header
GreatJonesStreet-Prod mh_execute_header
/usr/lib/system/libdispatch.dylib __dispatch_call_block_and_release
/usr/lib/system/libdispatch.dylib __dispatch_client_callout
/usr/lib/system/libdispatch.dylib __dispatch_queue_override_invoke
/usr/lib/system/libdispatch.dylib __dispatch_root_queue_drain
/usr/lib/system/libdispatch.dylib __dispatch_worker_thread3
/usr/lib/system/libsystem_pthread.dylib __pthread_wqthread
Run Code Online (Sandbox Code Playgroud)

我已经在多个地方读到其他人都遇到了这个问题,而Bugsnag(真是具有讽刺意味)似乎是在发现该问题时提到的常见问题。我并不是说Bugsnag是造成此问题的原因,但是人们一直在报告他们在Bugsnag报告中看到了崩溃日志。只是奇怪的巧合。

这是另一个:

EXC_BAD_ACCESS Attempted to dereference garbage pointer 0xa8a94beb8. 
/usr/lib/libobjc.A.dylib objc_msgSend
Frameworks/Foundation.framework/Foundation -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:usingBlock:]
Frameworks/Foundation.framework/Foundation -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:]
Frameworks/Foundation.framework/Foundation -[NSOperationQueue setMaxConcurrentOperationCount:]
GreatJonesStreet mh_execute_header
GreatJonesStreet mh_execute_header
GreatJonesStreet mh_execute_header
/usr/lib/system/libdispatch.dylib __dispatch_call_block_and_release
/usr/lib/system/libdispatch.dylib __dispatch_client_callout
/usr/lib/system/libdispatch.dylib __dispatch_queue_override_invoke
/usr/lib/system/libdispatch.dylib __dispatch_root_queue_drain
/usr/lib/system/libdispatch.dylib __dispatch_worker_thread3
/usr/lib/system/libsystem_pthread.dylib __pthread_wqthread
Run Code Online (Sandbox Code Playgroud)

在发布此问题时,上述错误中有75个发生在我们的56位用户中。

有人有想法么???

ios bugsnag react-native

6
推荐指数
0
解决办法
1224
查看次数

标签 统计

angular ×1

bugsnag ×1

components ×1

ios ×1

react-native ×1

unit-testing ×1