Базовый тестовый пример Angularjs с использованием кармы и жасмина, не работает

Я новичок в тестировании в angular. Ошибок по отработке кармы здесь нет. ожидаемый(true).toBe(true) и ожидаемый(false).toBe(true) дают тот же результат, что и ниже, я понятия не имею, почему.

karma start test/karma.conf.js
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 34.0.1847 (Mac OS X 10.9.2)]: Connected on socket VDytVxMpXMxN0QTPU_kg with id 83112246
Chrome 34.0.1847 (Mac OS X 10.9.2): Executed 0 of 0 ERROR (0.022 secs / 0 secs)

карма.conf.js

// Karma configuration

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

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '..',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      //'app/*/*.js'
      'app/bower_components/angular/angular.js',
        'app/bower_components/jquery/jquery.js',
       'app/bower_components/underscore/underscore-min.js',
        'app/bower_components/jquery.cookie/jquery.cookie.js',
        'app/bower_components/restangular/dist/restangular.min.js',
        'app/bower_components/angular-resource/angular-resource.min.js',
        'app/bower_components/angular-route/angular-route.min.js',
        'app/bower_components/angular-route-segment/build/angular-route-segment.min.js',
        'app/bower_components/angular-cookies/angular-cookies.js',
        'app/bower_components/angular-sanitize/angular-sanitize.js',
        'app/bower_components/angular-scenario/angular-scenario.js',
        'app/bower_components/angular-mocks/angular-mocks.js',
        'app/scripts/lib/ui-bootstrap-custom-0.10.0.min.js',
        'app/scripts/lib/jquery-ui-1.10.3.custom.js',
        'app/scripts/app.js',
        'app/scripts/config/*.js',
        'app/scripts/controllers/*.js',
        'app/scripts/directives/*.js',
        'app/scripts/services/*.js',
        'app/scripts/filters/*.js',

      'test/spec/controllers/main.js'
    ],


    // list of files to exclude
    exclude: [

    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {

    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],


    // web server port
    port: 9876,


    // 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
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false
  });
};

тест/спецификация/контроллеры/main.js

'use strict';

describe('Controller: MainCtrl', function () {

  it('should attach a list of awesomeThings to the scope', function () {
    expect(true).toBe(false);
  });
});

person rohit    schedule 13.05.2014    source источник
comment
тест не выполняется.   -  person mpm    schedule 13.05.2014
comment
почему тест не выполняется?   -  person rohit    schedule 13.05.2014
comment
пишет Executed 0 of 0 ERROR.   -  person mpm    schedule 13.05.2014
comment
что мне нужно сделать, чтобы он выполнил тест?   -  person rohit    schedule 13.05.2014


Ответы (1)


Поместите свой karma.conf.js в корневой каталог приложения, а затем просто запустите karma start.

Судя по выполняемой вами команде, файл конфигурации находится в каталоге test, но вы указали, что файл спецификации находится в каталоге test/spec/controllers. Я предполагаю, что это ошибка.

person Jaz Lalli    schedule 13.05.2014
comment
Да, изменение местоположения файла конфигурации сработало. Спасибо. - person rohit; 14.05.2014