2013-09-04 2 views
2

Я попытался запустить тесты E2E с Grunt Karma, но не успел. Я смотрю много решений, но никто не работал!AngularJS + Grunt + Karma + E2E

Моя карма-e2e.conf.js:

module.exports = function(config) { 
config.set({ 

    // base path, that will be used to resolve files and exclude 
    basePath: '../', 

    // frameworks to use 
    frameworks: ['ng-scenario'], 


    // list of files/patterns to load in the browser 
    files: [    
     'test/e2e/**/*.js', 
     'test/e2e/*.js' 
    ], 


    // list of files to exclude 
    exclude: [ 

    ], 

    // test results reporter to use 
    // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' 
    reporters: ['progress'], 


    // web server port 
    port: 9877, 


    // enable/disable colors in the output (reporters and logs) 
    colors: true, 


    // level of logging 
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 
    logLevel: config.LOG_INFO, 


    // enable/disable watching file and executing tests whenever any file changes 
    autoWatch: true, 


    // Start these browsers, currently available: 
    // - Chrome 
    // - ChromeCanary 
    // - Firefox 
    // - Opera 
    // - Safari (only Mac) 
    // - PhantomJS 
    // - IE (only Windows) 
    browsers: ['PhantomJS'], 


    // If browser does not capture in given timeout [ms], kill it 
    captureTimeout: 60000, 


    // Continuous Integration mode 
    // if true, it capture browsers, run tests and exit 
    singleRun: true, 

    // Uncomment the following lines if you are using grunt's server to run the tests 
    proxies: { 
     '/': 'http://localhost/test/e2e/' 
    }, 
    // URL root prevent conflicts with the site root 
    urlRoot: '/_karma_/' 
}); 

};

PS: Мое приложение работает в порту 80 (по умолчанию Apache).

Мой спецификации выглядит следующим образом:

describe('E2E: Testing Routes:', function() { 
'use strict'; 

beforeEach(function() { 
    browser().navigateTo('/'); 
}); 

it('should jump to the /videos path when/is accessed', function() { 
    browser().navigateTo('#/'); 
    expect(browser().location().path()).toBe("/main"); 
}); 

})

Таким образом, когда я запустил эту спецификацию, я получил это сообщение:

«Тип ошибки: не определено не является функцией (оценка $ document.injector()) «

Эта ошибка возникает в строке« ожидать (браузер(). location(). path()). toBe («/ main»);

Любая идея?

+0

Я советую посмотреть на транспортир, новый AngularJS E2E тестов бегуна. Он все еще находится в разработке, но у меня было меньше проблем с ним, чем с кармой и сценаристом. –

+0

посмотреть это сообщение: [http://stackoverflow.com/questions/15644908/getting-browser-path-in-angular-e2e-test-causes-an-exception](http://stackoverflow.com/ Вопросы/15644908/get-browser-path-in-angular-e2e-test-cause-the-exception) –

+0

Я уже видел это решение, но не работает. – vitorvigano

ответ

0

Убедитесь, что ваш веб-сервер работает и карма. Попробуйте изменить параметры прокси-сервера на что-то вроде этого:

proxies: { 
    '/': 'http://localhost:8000/' 
    }, 
+0

Я запускаю свой сервер в порту 80. (Apache Default). Я использовал прокси, но не добился успеха. – vitorvigano

0

Вам нужно

plugins: [ 
     'karma-ng-scenario', 
    ], 

в файле конфигурации.

ли npm install karma-ng-scenario --save-dev первый

Смежные вопросы