2015-05-24 63 views
0

我正在使用ember-cli-simple-auth並使用ember-cli-simple-auth-testing進行測試。我已按照README安裝測試庫。找不到變量:invalidateSession using ember-cli-simple-auth-testing

tests/helpers/start-app.js包含:

import Ember from 'ember'; 
import Application from '../../app'; 
import Router from '../../router'; 
import config from '../../config/environment'; 

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

export default function startApp(attrs) { 
    var application; 

    var attributes = Ember.merge({}, config.APP); 
    attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; 

    Ember.run(function() { 
    application = Application.create(attributes); 
    application.setupForTesting(); 
    application.injectTestHelpers(); 
    }); 

    return application; 
} 

config/environment.js包含:

... 
if (environment === 'test') { 
    // Testem prefers this... 
    ENV.baseURL = '/'; 
    ENV.locationType = 'none'; 

    // keep test console output quieter 
    ENV.APP.LOG_ACTIVE_GENERATION = false; 
    ENV.APP.LOG_VIEW_LOOKUPS = false; 

    ENV.APP.rootElement = '#ember-testing'; 

    ENV['simple-auth'] = { 
    store: 'simple-auth-session-store:ephemeral' 
    } 
} 
... 

當我打電話invalidateSession()在我的測試中,我得到以下錯誤:

Acceptance | items: the route /items is inaccessible when the session is not authenticated 
✘ Died on test #1  at http://localhost:7357/assets/test-support.js:2688 
    at http://localhost:7357/assets/wishlist.js:2055 
    at http://localhost:7357/assets/vendor.js:150 
    at tryFinally (http://localhost:7357/assets/vendor.js:30) 
    at http://localhost:7357/assets/vendor.js:156 
    at http://localhost:7357/assets/test-loader.js:29 
    at http://localhost:7357/assets/test-loader.js:21 
    at http://localhost:7357/assets/test-loader.js:40 
    at http://localhost:7357/assets/test-support.js:5460: Can't find variable: invalidateSession 

我一定做了什麼錯誤。它是什麼?

回答

0

爲0.8.0-beta.2正確導入:

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

export default function startApp(attrs) {