因此,我正在为使用 ember-simple-auth gem 进行登录验证的 Ember 应用程序编写 Qunit 测试(使用茶匙作为测试运行程序),我的测试如下( CoffeeScript ):
#= require qunit_spec_helper
test "Employee signs in", ->
expect(1)
visit("/login").then(->
fillIn "input.email", "employee1@example.com"
).then(->
fillIn "input.user_password", "password1"
).then(->
click "button.btn-primary"
).andThen ->
equal(find('h2').length,1, "Welcome to the App")
这是测试助手:
QUnit.testStart ->
Ember.run ->
App.reset()
Ember.testing = true
App.setupForTesting()
App.injectTestHelpers()
QUnit.testDone ->
Ember.testing = false
QUnit.done ->
Ember.run ->
App.reset()
当我运行测试(密切关注控制台)时,出现以下错误:
POST http://localhost:3000/teaspoon/qunit/oauth/token 404(未找到)
我似乎无法登录,无论如何.. 我没有想法,非常感谢任何帮助/建议:)
最佳答案
Ember.SimpleAuth 向服务器发出请求以在单击按钮时对 session 进行身份验证 - 尽管该路由未由您的服务器处理(或者服务器可能根本没有运行?)我会 stub 用于测试的 token 端点,找到一个例子,例如这里:https://github.com/digitalplaywright/eak-simple-auth/blob/master/tests/acceptance/login-test.js
关于javascript - Qunit 使用 ember-simple-auth 身份验证测试 Ember.js 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23138954/