【发布时间】:2015-09-03 04:36:27
【问题描述】:
我正在尝试使用速度/茉莉花框架为流星应用程序编写测试。
我的老板想要进行 UI 测试(端到端),所以我需要为用户界面编写测试。
我现在遇到了如何通过应用程序测试正常导航的问题。例如,我测试用户注册程序的想法是这样的:
describe 'Login and Usermanagement System', ->
it 'should say the user is logged out when no user is logged in', ->
# This test Works
expect(Meteor.user()).toBeFalsy()
it 'should show a welcome screen if the user is logged out', ->
currentUrl = Router.current().location.get().href;
routeName = Router.current().route.getName();
# This test Works as the startpage in our app (When you hit /) is always system.welcome as long as you are not logged in.
expect(routeName).toBe("system.welcome")
it 'should show a register screen if the user is logged out and clicked on register', (done) ->
Router.go("/register")
routeName = Router.current().route.getName()
# This test does not work as the Router.go seems to be async.
expect(routeName).toBe("system.register")
我的问题是第三次测试。当路由加载完成下一件事情时,我需要某种回调。我可以等待 2 秒左右,但这会不必要地减慢我的测试速度。
是否有 Router.go(route, options, callback) 这样的东西或者我怎样才能得到这样的行为?
我们使用的技术:MeteorJS 和 Iron Router 进行路由,Velocity Test Framework 和 Jasmine 进行测试。
【问题讨论】:
标签: meteor jasmine iron-router