WARN [PhantomJS 1.9.8 (Mac OS X)]: disabled (1 time) because there is no message in 10,000 ms

My project is ion-angled-requirejs
My environment is Mac OS X 10.10.1, node v0.10.30

I would like to integrate the karma test into my project, but this is an error when running the grunt test :

Result:

 Running "karma:unit" (karma) task INFO [karma]: Karma v0.12.28 server started at http://localhost:9876/ INFO [launcher]: Starting browser PhantomJS INFO [PhantomJS 1.9.8 (Mac OS X)]: Connected on socket UhgMIttDejE4Xdm8I7mG with id 52208731 WARN [PhantomJS 1.9.8 (Mac OS X)]: Disconnected (1 times), because no message in 10000 ms. Warning: Task "karma:unit" failed. Use --force to continue. Aborted due to warnings. 


Here are the dependencies in my package.json:

 "grunt-bower-requirejs": "^1.1.1", "grunt-contrib-uglify": "^0.2.7", "grunt-karma": "^0.9.0", "karma": "^0.12.28", "karma-jasmine": "^0.3.2", "karma-phantomjs-launcher": "^0.1.4", "karma-requirejs": "^0.2.2", "requirejs": "^2.1.15" 

Here is my Gruntfile.js:

 module.exports = function (grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), bower: { target: { rjsConfig: 'js/main.js' } }, uglify: { options: { banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' }, build: { src: 'src/<%= pkg.name %>.js', dest: 'build/<%= pkg.name %>.min.js' }, }, karma: { unit: { options: { frameworks: ['jasmine', 'requirejs'], browsers: ['PhantomJS'], autoWatch: true, singleRun: true, files: [ 'lib/js/generated/angular/angular.js', 'lib/js/generated/angular-mocks/angular-mocks.js', //'js/**/*.js', //'templates/**/*.html', 'tests/*.tests.js' ], exclude: [ 'js/main.js' ] } } } }); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-bower-requirejs'); grunt.loadNpmTasks('grunt-karma'); // Tell Grunt what to do when we type "grunt" into the terminal grunt.registerTask('default', [ 'uglify', 'bower' ]); grunt.registerTask('test', [ 'karma' ]); 

};

+6
source share
1 answer

My experience of using the grunt-karma plugin was such that I spend more time debugging the plugin than on my actual site. My solution is to exclude it completely and use grunt-exec to run my karma command or just not use grunt and start karma manually in a new tab.

 grunt.loadNpmTasks('grunt-exec'); var config = { exec: { karma : 'karma start {path to your karma.conf.js file}' // or // karma : 'karma run {path to your karma.conf.js file}' } } 

I know that this is probably not the answer you are looking for, but my experience has led me to realize that every step you get from the original program is just an extra program that you have to debug, which is not yours own.

WHAT, being said, your files do not seem to be included.

I usually split the karma configuration file into separate files:

config /files.js

 module.exports = [ 'public/lib/angular/angular.js', 'public/lib/lodash/dist/lodash.compat.js', 'public/lib/jquery/dist/jquery.js', 'public/lib/angular-ui-router/release/angular-ui-router.js', 'tests/test-main.js', {pattern: 'public/js/**/*.js', included: true}, {pattern: 'tests/unit/**/*.js', included: true} ]; 

config /common.conf.js

 var files = require('./files.js'); module.exports = { // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '../', frameworks: ['jasmine', 'requirejs'], // list of files / patterns to load in the browser files: files, // list of files to exclude exclude: [ ], // web server port port: 9876, // enable / disable colors in the output (reporters and logs) colors: true, // enable / disable watching file and executing tests whenever any file changes autoWatch: true, coverageReporter: { type : 'html', dir : './tests/coverage/', subdir: function(browser) { "use strict"; // normalization process to keep a consistent browser name accross different // OS return browser.toLowerCase().split(/[ /-]/)[0]; } }, }; 

config /karma.conf.js

var commonConfig = require ('./common.conf.js');

 module.exports = function(config) { "use strict"; commonConfig.reporters = ['nyan', 'growl']; commonConfig.browsers = ['PhantomJS']; commonConfig.captureTimeout = 60000; commonConfig.singleRun = false; commonConfig.logLevel = config.LOG_DEBUG; config.set(commonConfig); }; // commonConfig.browsers = ['PhantomJS', 'Chrome'] // commonConfig.browsers = ['PhantomJS', 'Chrome', 'Safari', 'Firefox'], 

config /build.conf.js

 var commonConfig = require('./common.conf.js'); module.exports = function(config) { "use strict"; commonConfig.reporters = ['progress']; commonConfig.browsers = ['PhantomJS']; commonConfig.captureTimeout = 120000; commonConfig.singleRun = true; commonConfig.logLevel = config.LOG_DEBUG; config.set(commonConfig); }; 

config /test.coverage.js

 var commonConfig = require('./common.conf.js'); module.exports = function(config) { "use strict"; commonConfig.reporters = ['progress','coverage']; commonConfig.browsers = ['PhantomJS', 'Chrome', 'Safari', 'Firefox']; commonConfig.captureTimeout = 120000; commonConfig.singleRun = true; commonConfig.logLevel = config.LOG_DEBUG; commonConfig.preprocessors = {}; commonConfig.preprocessors['./public/js/*.js'] = ['coverage']; config.set(commonConfig); }; 

which allows me to run different karma configurations for different situations.

In development, I use: karma start config / karma.conf.js

To get my test coverage in all browsers, I would run: karma start config / test.coverage.js

and make sure my builds are clean as part of my ongoing integration process that I run karma start config / build.conf.js

Using this method, I can again use grunt-exec to run these commands at appropriate times.

0
source

Source: https://habr.com/ru/post/979153/


All Articles