首页 文章

未定义Ember CLI Simple Auth测试助手authenticateSession

提问于
浏览
1

我使用的是ember-cli 0.2.6和ember-cli-simple-auth 0.8.0-beta.2 .

从头开始我执行以下操作:

ember create project1
//inside project1
ember install ember-cli-simple-auth

现在我将以下行添加到tests / helpers / start-app:

import 'simple-auth-testing/test-helpers';

并在environment.js中只添加:

if (environment === 'test') {
    ENV['simple-auth'] = {
      store: 'simple-auth-session-store:ephemeral'
    };
    ...
}

我还创建了一个名为“登录”的验收测试

ember generate acceptance-test login

我调整了哪些来使用 authenticateSession(); 助手:

import Ember from 'ember';
import {
  module,
  test
} from 'qunit';
import startApp from 'project1/tests/helpers/start-app';

var application;

module('Acceptance: Login', {
  beforeEach: function() {
    application = startApp();
  },

  afterEach: function() {
    Ember.run(application, 'destroy');
  }
});

test('visiting /login', function(assert) {
  authenticateSession();
  ok('yes');
});

然而,现在每当我运行 ember test 时,我收到相同的错误消息:

acceptance/login-test.js: line 22, col 3, 'authenticateSession' is not defined.

我错过了什么,无法访问验收测试中的简单验证助手?我也尝试使用simple-auth 0.7.3版本,...在另一次尝试中我设置了一个自定义授权器,但得到了同样的错误 .

1 回答

  • 2

    您需要像这样导入测试助手:

    import initializeTestHelpers from 'simple-auth-testing/test-helpers';
    initializeTestHelpers();
    

相关问题