Pregunta

I am new to testing in angular. There are no errors on running karma here . expected(true).toBe(true) and expected(false).toBe(true) give the same output as below, i have no idea why.

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)

karma.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
  });
};

test/spec/controllers/main.js

'use strict';

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

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

Solución

Put your karma.conf.js in the apps root directory and then just run karma start.

From the command you're running, it looks like the config file is in the test directory, but you've specified that the spec file is in test/spec/controllers. I'm guessing that's a mistake.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top