0

I had an existing build using Maven, Karma, PhantomJS, and Jasmine working in Windows7, using a Cygwin Bash shell.

I'm now trying to get the same build running on a CentOS VM pointing to the same workspace.

When I run Karma on the VM, it starts Karma and PhantomJS "because no message in 10000 ms". I tried increasing the capture timeout, but that made no difference.

Is there something I can do to get more diagnostics that might tell me why no messages are getting to PhantomJS from Karma?

On Windows, I'm using Karma v0.12.16 and PhantomJS 1.9.7. On the CentOS VM, I'm using Karma v0.12.24 and PhantomJS 1.9.8.

Here's my "karma.config.js":

module.exports = function(config) {
    'use strict';
  config.set({
basePath: '../../../..',
frameworks: ['jasmine'],
files: [
    "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js",
    "http://code.jquery.com/jquery-migrate-1.2.1.js",
    "src/main/webapp/js/libs/jquery.coo.kie.js",
    "src/main/webapp/js/libs/jquery.address-1.3.1.js",
    "src/main/webapp/js/libs/modernizr-1.6.min.js",
    "src/main/webapp/js/libs/underscore.js",
    "src/main/webapp/js/mylibs/util.js",
    "src/main/webapp/js/mylibs/controller.js",
    "src/test/webapp/js/init.js",
    "src/main/webapp/js/mylibs/config.js",
    "src/main/webapp/js/mylibs/controller.daily.js",
    "src/main/webapp/js/mylibs/controller.daily.rate-table.js",
    "src/main/webapp/js/mylibs/controller.diagnostic.page.js",
    "src/main/webapp/js/mylibs/controller.realtime.matrix-view.js",
    "src/main/webapp/js/mylibs/controller.realtime.rate-table.js",
    "src/main/webapp/js/mylibs/controller.realtime.subway-map.js",
    "src/main/webapp/js/mylibs/data.daily.js",
    "src/main/webapp/js/mylibs/data.realtime.js",
    "src/main/webapp/js/mylibs/diagnostic.controller.js",
    "src/main/webapp/js/mylibs/html.js",
    "src/main/webapp/js/mylibs/html.daily.js",
    "src/main/webapp/js/mylibs/html.diagnostic.js",
    "src/main/webapp/js/mylibs/html.realtime.js",
    "src/main/webapp/js/mylibs/html.realtime.matrix-view.js",
    "src/main/webapp/js/mylibs/routes.js",
    "src/main/webapp/js/mylibs/uverse.config.js",
    "src/test/webapp/js/data.daily.test.js",

    "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js",
    "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular-resource.js",
    "src/test/webapp/js/libs/angular-mocks.js",
    "src/main/webapp/js/diag/libs/ui-bootstrap-tpls-0.10.0.js",
    "src/main/webapp/js/diag/libs/ng-table.src.js",
    "src/main/webapp/js/diag/constants.js",
    "src/main/webapp/js/diag/diagapp.js",
    "src/main/webapp/js/diag/diagMod.js",
    "src/main/webapp/js/diag/dataSourcesMod.js",
    "src/main/webapp/js/diag/queriesMod.js",
    "src/main/webapp/js/diag/handlersMod.js",
    "src/main/webapp/js/diag/workflowMappingsMod.js",
    "src/main/webapp/js/diag/configurationMod.js",
    "src/main/webapp/js/diag/commonErrorsMod.js",

    "src/test/webapp/js/diag/diagapp.test.js"
    ],
exclude: [
],
plugins:[
     'karma-jasmine',
     'karma-coverage',
     'karma-junit-reporter',
     'karma-phantomjs-launcher',
     'karma-chrome-launcher',
     'karma-firefox-launcher',
     'karma-ie-launcher'
     ],
preprocessors: {
    "src/main/webapp/js/mylibs/*.js": 'coverage',
    "src/main/webapp/js/diag/*.js": 'coverage',
},
coverageReporter: {
    type: "lcov",
    dir: "target/karma-coverage"
},
junitReporter: {
    outputFile: 'target/surefire-reports/TEST-karma.xml'
},
reporters: ['dots', 'junit'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
captureTimeout: 60000,
singleRun: false
  });
};

And here is the Karma command line I'm running:

karma start /media/sf_Users/<myuid>/workspace2/SunlightGUI/src/test/webapp
  /js/karma.conf.js --browsers PhantomJS --reporters dots,junit,coverage
  --single-run --no-auto-watch --colors false --log-level info
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
David M. Karr
  • 14,317
  • 20
  • 94
  • 199

1 Answers1

0

Use the following process:

  • Open karma.conf.js
  • Remove websocket from transports:

    transports: ['flashsocket', 'xhr-polling', 'jsonp-polling']
    
  • Use polling:

    usePolling: true
    
  • Use require("os").cwd() to get the absolute path

  • Use a variable to store the absolute path with a slash, such as:

    var foo = process.cwd() + "/";
    config.set({
               basePath: foo,
    
  • Prefix each path in the files array with the absolute path, for example:

    foo + 'src/test/webapp/js/diag/diagapp.test.js',
    

References

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265