我最近成功获得了我的ember-auth tests to pass,但它还不完美,因为测试每隔一次失败(或者如果有几个测试运行,那么关于身份验证的每一次测试失败)。
我创建了一个small sample app来证明失败。
您应该能够通过以下步骤重现失败:
1. git clone https://github.com/pedrokost/ember_auth_testing_example.git
2. cd ember_auth_testing_example
3. ruby -run -e httpd . -p5000 # (or any HTTP server like: python -m SimpleHTTPServer)
4. Open http://localhost:5000?test in the browser
如果测试通过,请刷新页面并使用“无效的JSON格式”查看它。下次刷新它再次有效。
答案 0 :(得分:1)
使用本地存储保存会话时遇到了这个问题。这是因为默认情况下,余烬测试不会清除本地存储。至少有三种方法可以解决这个问题:
第一个解决方案似乎是最简单和最好的解决方案,因为可以将存储设置为仅适用于Ember Auth。 ember-auth文档explains存储选项:
曲奇
App.Auth = Em.Auth.extend
session: 'dummy'
虚拟(用于单元测试)
App.Auth = Em.Auth.extend
session: 'cookie'
如果Ember.testing === true