1
票
Accepted
jasmineでExpected spy scroll to have been called
自己解決しました。subscribeは非同期なのでfakeAsyncを使ってtickで待てばexpectで評価されました。
it('test', fakeAsync(() => {
let router: Router;
router = TestBed.get(Router);
spyOn(window, "scroll");
router....
1
票
Accepted
jasmine使用時、$httpBackendのrespondで応答を設定できない
$httpBackendのレスポンスを受け取るには明示的にflush()メソッドを呼ぶ必要があります。テストの最後に$httpBackend.flush()の1文を加えてみてください。
it('should say hello', function() {
$httpBackend.expect('GET', 'testData.json').respond('hello');
...
1
票
onsenuiがユニットテストでエラーが発生する
ons.isWebView()をスパイして常にtrueを返すようにするといいです。
describe('OnsenUIのテスト', function() {
beforeEach(function() {
spyOn(ons, 'isWebView').and.returnValue(true);
});
it('テストサンプル', function() {
// ...
Only top scored, non community-wiki answers of a minimum length are eligible