【发布时间】:2015-04-03 19:34:17
【问题描述】:
我正在编写需要身份验证的流星测试,但遇到了一系列问题。 这是我的代码:
MochaWeb?.testOnly ->
describe "Login", ->
describe "security", ->
it 'should take you to /login/ if you are not logged in', ->
Meteor.flush()
chai.assert.equal Router.current().url, '/login/'
it 'should allow logins and then take us to /', ->
Meteor.flush()
Accounts.createUser username: 'test', password: 'test'
Meteor.loginWithPassword 'test', 'test', (err) ->
console.log err
chai.expect(err).to.be undefined
chai.assert.equal Router.current().url, '/'
我的测试通过了,即使我收到控制台消息,例如 Exception in delivery result of invoking 'login': TypeError: object is not a function
-
我的 console.log 调用给了我
{error: 403, reason: "User not found", details: undefined, message: "User not found [403]", errorType: "Meteor.Error"…}
在控制台上,速度日志窗口上什么都没有
- 我的用户未按预期进行身份验证。一个原因可能是我的应用程序没有帐户密码包,因为我不想要它(我只希望谷歌应用程序用户能够登录)。不过,我想要一种简单的方法来处理流星测试中的身份验证,因为我的大多数测试都涉及经过身份验证的用户。
- 我不确定 assert equal 是否有效,或者我必须设置某种超时来等待重定向。在这种情况下,这不是问题,但是我是否必须将我拥有的每个测试方法都嵌套在 loginWithPassword 中?我会觉得这有点不舒服。
非常感谢任何帮助和建议!
最好的,
【问题讨论】:
-
嘿,您可以在哪里使测试成功,谢谢
-
我对任何解决方案都不太信服,这就是为什么我还没有尝试过它们的原因。我真的认为应该有一种方法可以让登录状态不受干扰并专注于实际测试,就像成熟的框架一样。与此同时,我试图避免在 Meteor 中进行这种测试。
标签: testing meteor mocha.js velocity