2017-10-06 3 views
0

로그인 공식을위한 엠버 테스트 파일을 작성했습니다. 리디렉션 페이지는 타임 티커 사이드 바가있는 대시 보드입니다. 자, 내가 이것을 테스트했을 때, 나는 60000ms 후에 테스트 타임 아웃이되었다. 엠버 테스트에서 타임 티커 구성 요소를 제외 할 수 있습니까?Ember 테스트를 통한 로그인 테스트

내 테스트 코드 :

import {test} from 'qunit'; 
import moduleForAcceptance from 'frontend/tests/helpers/module-for-acceptance'; 

moduleForAcceptance('Acceptance | Login', { 
    integration: true 
}); 

test('visiting /user_session/new', function (assert) { 
    visit('/user_session/new'); 
    fillIn('input#login-email', '[email protected]'); 
    fillIn('input#login-password', 'blabla'); 
    click('button.btn-primary'); 

    let done = assert.async(); 

    andThen(() => { 
    Ember.run.later(null,() => { 
     assert.equal(currentURL(), '/dashboard', 'redirects to the dashboard'); 
     done(); 
    }, 1000); 
    }); 
}); 

타임 티커 구성 요소 :

import Ember from 'ember'; 

export default Ember.Component.extend({ 
    tagName: 'time', 

    date: moment().format('DD.MM.YYYY'), 

    time: Ember.computed('value', function() { 
    return moment().format('HH:mm:ss'); 
    }), 

    didInsertElement: function() { 
    this.tick(); 
    }, 

    tick: function() { 
    this.set('nextTick', Ember.run.later(this, function() { 
     this.notifyPropertyChange('value'); 
     this.tick(); 
    }, 1000)); 
    }, 

    willDestroyElement: function() { 
    Ember.run.cancel(this.get('nextTick')); 
    } 
}); 

답변

0

랩 똑 딱 서비스 장치 및 구성 요소에 해당 서비스를 사용합니다.

테스트하는 동안 서비스를 조롱하고 구성품에 모의 삽입하기. 수락 테스트를 조롱하는 것이 나에게는 좋지 않지만,이 시나리오에서는 조롱하는 방식으로 갈 수 있습니다.

ember-moment의 라이브 업데이트를 페이지에서 사용할 수도 있습니다. 실시간 업데이트를 제공합니다. Here 있습니다.

+0

오, 예, 좋은 생각입니다. 감사합니다. – Daniel