2016-10-18 3 views
0

bei dem Versuch, PhantomJS 2.1.1 mit Karma 1.3.0 zu laufen, bekomme ich Fehler:Karma Fehler: Typeerror: kann nicht eingestellt Eigenschaft 'Ergebnisse' undefinierter

[33mWARN [PhantomJS 2.1.1 (Linux 0.0.0)]: [39mDisconnected (1 times), because no message in 10000 ms. 
[31mERROR [karma]: [39m[TypeError: Cannot set property 'results' of undefined] 
TypeError: Cannot set property 'results' of undefined 
    at onBrowserComplete (/opt/jenkins/workspace/PHANTOMJS-2.1.1/Apps/InternalApp/InternalApp/node_modules/karma-html-reporter/index.js:43:25) 
    at null.<anonymous> (/opt/jenkins/workspace/PHANTOMJS-2.1.1/Apps/InternalApp/InternalApp/node_modules/karma/lib/events.js:14:22) 
    at emitOne (events.js:82:20) 
    at emit (events.js:169:7) 
    at null._onTimeout (/opt/jenkins/workspace/PHANTOMJS-2.1.1/Apps/InternalApp/InternalApp/node_modules/karma/lib/browser.js:50:15) 
    at Timer.listOnTimeout (timers.js:92:15) 

hier mein karma.conf.js ist

module.exports = function(config) { 
    var isSingleRun = false; 

    var pluginsToLoad = [ 
    'karma-jasmine', 
    'karma-chrome-launcher', 
    'karma-commonjs', 
    'karma-phantomjs-launcher', 
    'karma-firefox-launcher', 
    'karma-coverage', 
    'karma-ng-html2js-preprocessor' 
    ]; 

    var reportersToLoad = ['progress', 'coverage']; 
    var browsers = ['PhantomJS']; 
    // turn off all pre-processors that might be interfering with line numbers in karma errors. 
    var sourcePreprocessors = ['coverage']; 
    var templatePreprocessors = ['ng-html2js']; 

    var codeSrc = 'src/main/core/app/'; 
    var testSrc = 'src/test/core/'; 
    var filesToInclude = [ 
    'node_modules/jquery/dist/jquery.min.js', 
    codeSrc + 'libs/jquery-ui-1.10.4/jquery-ui-1.10.4.js', 
    codeSrc + 'libs/jqueryDatatables-1.9.4/jquery.dataTables.js', 

    'node_modules/jasmine-core/lib/jasmine-core/jasmine.js', 
    'node_modules/jasmine-core/lib/jasmine-core/jasmine.css', 
    'node_modules/jasmine-jquery/lib/jasmine-jquery.js', 

    codeSrc + 'libs/angular/angular.js', 
    codeSrc + 'libs/angular/angular-cookies.js', 
    'node_modules/angular-mocks/angular-mocks.js', 

    codeSrc + 'libs/angular/angular-resource.min.js', 
    codeSrc + 'libs/lodash/lodash.compat.min.js', 

    codeSrc + 'libs/bootstrap/*.js', 
    codeSrc + 'libs/moment/2.0.0/moment.min.js', 

    codeSrc + '../common/**/*.js', 

    codeSrc + 'internal/**/*.module.js', 
    codeSrc + 'internal/**/*.controller.js', 
    codeSrc + 'internal/**/*.directive.js', 
    codeSrc + 'internal/**/*.service.js', 
    codeSrc + 'internal/**/*.filter.js', 

    testSrc + 'shared/testUtils.js', 
    'src/main/webapp/app/app_templates.js', 
    'src/main/webapp/app/metis_templates.js' 
    ]; 

    var testFilesToPush = [ 
         testSrc + 'shared/**/*.test.js', 
         testSrc + 'shared/**/*.mock.js', 

         ]; 
    function runSingleTestFile(file) { 
    testFilesToPush = [testSrc + '**/' + file]; 
    } 

    for (var i = 0; i < process.argv.length; i++) { 
     var arg = process.argv[i]; 
     switch(arg) { 
     case '--debug': { 
      sourcePreprocessors = []; 
      break; 
     } 
     case '--browser': { 
      browsers = [process.argv[++i]]; 
      break; 
     } 
     case '--file': { 
      runSingleTestFile(process.argv[++i]); 
      break; 
     } 
     } 
    } 

    filesToInclude = filesToInclude.concat(testFilesToPush); 

    // determine if and set parameters for pipeline build 
    function isBuildMinion(argument) { 
    return argument === '--pipeline'; 
    } 
    if (process.argv.some(isBuildMinion)) { 
    console.log("running in pipeline: limiting plugins and will not run continuously"); 

    pluginsToLoad = [ 'karma-jasmine', 'karma-commonjs', 'karma-phantomjs-launcher', 'karma-ng-html2js-preprocessor','karma-coverage','karma-html-reporter' ]; 
    isSingleRun = true; 
    sourcePreprocessors = ['coverage']; 

    reportersToLoad = ['coverage','html']; 
    } 

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

    frameworks: ['jasmine'], 

    // list of files/patterns to load in the browser 
    files: filesToInclude, 


    // list of files to exclude 
    exclude: [ 
     'client/main.js' 
    ], 

    // use dots reporter, as travis terminal does not support escaping sequences 
    // possible values: 'dots', 'progress' 
    // CLI --reporters progress 
    reporters: reportersToLoad, 

    preprocessors: { 
     'src/main/core/app/internal/**/*.js': sourcePreprocessors, 
     'src/main/core/app/metis/components/**/*.js': sourcePreprocessors 
    }, 

    // web server port 
    // CLI --port 9876 
    port: 9876, 

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

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

    // enable/disable watching file and executing tests whenever any file changes 
    // CLI --auto-watch --no-auto-watch 
    autoWatch: true, 

    coverageReporter: { 
     type : 'html', 
     dir : 'build/karma/coverage/' 
    }, 

    htmlReporter: { 
     outputDir: 'build/karma/html', // where to put the reports 
     focusOnFailures: true, // reports show failures on start 
    }, 

    ngHtml2JsPreprocessor: { 
     stripPrefix: '.*/static', 
     prependPrefix: '/metis', 
    }, 

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

    // If browser does not capture in given timeout [ms], kill it 
    // CLI --capture-timeout 5000 
    captureTimeout: 20000, 

    // Auto run tests on start (when browsers are captured) and exit 
    // CLI --single-run --no-single-run 
    singleRun: isSingleRun, 

    // report which specs are slower than 500ms 
    // CLI --report-slower-than 500 
    reportSlowerThan: 500, 

    plugins: pluginsToLoad 
    }); 
}; 

von der Kommandozeile:

karma start 
INFO [karma]: Karma v0.12.37 server started at http://localhost:9876/ 
INFO [launcher]: Starting browser PhantomJS 
INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket JfQHKGDH0YODbO1ftHs7 with id 87652824 
WARN [web-server]: 404: /InternalApp/rest/toggles/ui/AnalyticsFiles 

und mit der Pipeline Option

karma start --pipeline 
running in pipeline: limiting plugins and will not run continuously 
INFO [karma]: Karma v0.12.37 server started at http://localhost:9876/ 
INFO [launcher]: Starting browser PhantomJS 
INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket 3Ic05jImtEagaUWHuVlU with id 45163428 
WARN [PhantomJS 2.1.1 (Linux 0.0.0)]: Disconnected (1 times), because no message in 10000 ms. 
ERROR [karma]: [TypeError: Cannot set property 'results' of undefined] 
TypeError: Cannot set property 'results' of undefined 
    at onBrowserComplete (/opt/jenkins/workspace/PHANTOMJS-2.1.1/Apps/InternalApp/InternalApp/node_modules/karma-html-reporter/index.js:43:25) 
    at null.<anonymous> (/opt/jenkins/workspace/PHANTOMJS-2.1.1/Apps/InternalApp/InternalApp/node_modules/karma/lib/events.js:14:22) 
    at emitOne (events.js:82:20) 
    at emit (events.js:169:7) 
    at null._onTimeout (/opt/jenkins/workspace/PHANTOMJS-2.1.1/Apps/InternalApp/InternalApp/node_modules/karma/lib/browser.js:50:15) 
    at Timer.listOnTimeout (timers.js:92:15) 

Antwort

0

es stellt sich heraus, dass die Ursache des Fehlers war Karma nicht zu finden/PhantomJS abzufeuern, so war die Lösung:

sudo npm install phantomjs-prebuilt --save-dev 

dies ausgeführt wird, wo die% ROOT von JavaScript befindet, oder wo package.json befindet sich

npm Link Phantomjs könnte auch

gearbeitet haben
Verwandte Themen