使用Mocha测试Ember - visit()会导致测试中止

时间:2014-06-03 05:21:46

标签: javascript testing ember.js phantomjs mocha

运行visit()时,Ember过渡正确: Transitioned into 'auth'

然而,PhantomJs不加载: [D] ["phantomjs","onLoadFinished","fail"]

如何解决这个问题,为什么visit()不起作用?


细节:

在使用yo ember生成的项目中,我有以下测试规范:

    var assert = chai.assert;
    var expect = chai.expect;
    var should = chai.should();

    App.rootElement = '#main';
    App.setupForTesting();
    App.injectTestHelpers();

    (function () {
        'use strict';

        beforeEach(function() {
            Ember.run(function() {
                App.reset();
            });
            Ember.testing = true;
        });

        afterEach(function() {
            Ember.testing = false;
        });

        describe('Basic', function () {

            describe('Smoke test', function() {
                visit('/auth');

                it('Should contain a header', function() {
                    expect($('.main').length).to.equal(1);
                });
            });
        });
    })();

当我运行grunt test --debug时,我得到以下输出:

    [D] ["phantomjs","console","generated -> controller:application [object Object]"]
    generated -> controller:application [object Object]
    [D] ["phantomjs","console","Rendering application with default view <(subclass of Ember.View):ember650> [object Object]"]
    Rendering application with default view <(subclass of Ember.View):ember650> [object Object]
    [D] ["phantomjs","console","Rendering auth with <App.AuthView:ember664> [object Object]"]
    Rendering auth with <App.AuthView:ember664> [object Object]
    [D] ["phantomjs","console","Transitioned into 'auth'"]
    Transitioned into 'auth'
    [D] ["phantomjs","onLoadFinished","fail"]
    [D] ["phantomjs","fail.load","http://localhost:9001/index.html"]
    ...ERROR
    Warning: PhantomJS unable to load "http://localhost:9001/index.html" URI. Use --force to continue.

    Aborted due to warnings.

0 个答案:

没有答案