mercredi 26 octobre 2016

karma+jasmine testing issue when Fuse Angular APP injects module

y setup a karma+jasmine testing in my Fuse App (withinpixels[dot]com/themes/fuse), based on AngularJS+Gulp project, with the next config files:

karma.conf.js:

// Karma configuration
// Generated on Tue Oct 25 2016 11:50:38 GMT+0200 (CEST)

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: http://ift.tt/1ft83uu
        frameworks : ['jasmine'],

        // list of files / patterns to load in the browser
        files : [
            'bower_components/angular/angular.js',
            'bower_components/angular-mocks/angular-mocks.js',
            'src/app/**/*.json',
            'src/app/**/*.js',
            'test/*.js'
        ],

        // list of files to exclude
        exclude : [
        ],

        // preprocess matching files before serving them to the browser
        // available preprocessors: http://ift.tt/1gyw6MG
        preprocessors : {
            'src/app/**/*.json' : ['json_fixtures'],
            'src/app/**/*.js' : ['coverage']
        },

        coverageReporter : {
            type : 'text-summary',
            dir : 'coverage/'
        },

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: http://ift.tt/1ft83KQ
        reporters : ['progress', 'coverage'],

        // 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: http://ift.tt/1ft83KU
        browsers : ['PhantomJS'], //['Chrome'],


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

        plugins: [
            'karma-jasmine',
            'karma-coverage',
            'karma-phantomjs-launcher',
            'karma-json-fixtures-preprocessor'
        ],


        // Concurrency level
        // how many browser should be started simultaneous
        concurrency : Infinity
    });
};

test/test.js:

describe("Index/Module", function () {
    var rootScope, scope, ctrl;

    beforeEach(angular.mock.module('fuse'));

    beforeEach(inject(function($rootScope, $controller) {
        rootScope = $rootScope;
        scope = rootScope.$new();

        ctrl = $controller("IndexController", {
            $scope: scope
        });
    }));

    it("exists", function() {
        expect(ctrl).not.toBeUndefined();
    });
});

And when i execute the test, i obtain the next error message:

[PhantomJS 2.1.1 (Mac OS X 0.0.0)] ERROR: Error: [$injector:nomod] Module 'app.core' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://ift.tt/28PuMbI$injector/nomod?p0=app.core at http://localhost:9876/base/bower_components/angular/angular.js?628a6cd3a27859d17a9a4ee87e62c9b6996ba4cb:2077

Uncaught errors occured. Full output can be verified in Output window.

¿Any idea?

Aucun commentaire:

Enregistrer un commentaire