Karma can't capture PhantomJS - node.js

We've set up a Jenkins CI server running Karma targeting PhantomJS. We're running our tests through Grunt. Jenkins, Grunt, and Phantom are all running correctly, and Karma seems to start up fine, but Karma can't capture Phantom. Our scripts run locally (OSX) just fine. The same error exists running via bash or through Jenkins:
Running "karma:jenkins-unit" (karma) task
[2013-07-03 11:03:12.168] [WARN] config - urlRoot normalized to "/__karma/"
DEBUG [reporter]: Using reporter "dots".
DEBUG [reporter]: Using reporter "junit".
DEBUG [reporter]: Using reporter "coverage".
INFO [karma]: Karma server started at http://localhost:8084/__karma/
INFO [launcher]: Starting browser PhantomJS
DEBUG [launcher]: Creating temp dir at /tmp/testacular-7720703
DEBUG [launcher]: phantomjs /tmp/testacular-7720703/capture.js
INFO [karma]: To run via this server, use "karma run --runner-port 9104"
...
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
DEBUG [launcher]: Process PhantomJS exitted with code 0
DEBUG [launcher]: Cleaning temp dir /tmp/testacular-7720703
INFO [launcher]: Trying to start PhantomJS again.
DEBUG [launcher]: Creating temp dir at /tmp/testacular-7720703
DEBUG [launcher]: phantomjs /tmp/testacular-7720703/capture.js
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
DEBUG [launcher]: Process PhantomJS exitted with code 0
DEBUG [launcher]: Cleaning temp dir /tmp/testacular-7720703
INFO [launcher]: Trying to start PhantomJS again.
DEBUG [launcher]: Creating temp dir at /tmp/testacular-7720703
DEBUG [launcher]: phantomjs /tmp/testacular-7720703/capture.js
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
DEBUG [launcher]: Process PhantomJS exitted with code 0
DEBUG [karma]: PhantomJS failed to capture, aborting the run.
DEBUG [launcher]: Disconnecting all browsers
DEBUG [launcher]: Killing PhantomJS
DEBUG [launcher]: Cleaning temp dir /tmp/testacular-7720703
Warning: Task "karma:jenkins-unit" failed. Use --force to continue.
Our server is CentOS 6.4.
Here are the versions we have running:
grunt-cli v0.1.9
grunt v0.4.1
node 0.10.12 and 0.8.25.
phantomjs 1.9.1
karma 0.8.6
Any help would be much appreciated!

Use polling instead of sockets and absolute paths instead of relative paths in the karma.conf.js configuration file to ensure the directory structure is being traversed correctly and the client/server connection has no external dependencies:
module.exports = function(config)
{
var absolute_root = process.cwd() + '/';
config.set
(
{
// https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files
files:
[
absolute_root + 'test/Spec/**/*.js',
absolute_root + 'js/*.js',
absolute_root + '../libs/jquery.js'
],
usePolling: true,
transports: ['xhr-polling', 'jsonp-polling'],
browsers: ['PhantomJS']
}
);
};
References
Karma is not able to run test cases on phantomJS
Karma doesn't exit properly when using public api with the finish callback
AngularJS + Socket.IO + karma not working in karma 0.8.5
Karma Runner Hangs Indefinitely
Preprocessors not running in Jenkins(Linux)
"basePath" is relative to "C:\" instead of config file
Karma config.js
Istanbul/coverage reporter generate LCOV file with relative path for SF parameter instead of absolute path

In my case adding
transports: ['xhr-polling', 'jsonp-polling']
to karma.conf.js was sufficient. The real problem was a very old version of karma (0.12). Now with 1.4. I don't need CPU consuming polling.

Related

gulp trust-dev-cert without error, but access the page still failed

After I upgrade my Nodejs to v9.3.0 and NPM to 5.5.1, failed to access the gulp serve server. The browser show the unsafe TLS security error.
I have removed ~.gcb-serve-data/, and run the gulp trust-dev-cert without error, but I cannot find the cert in my trust certificates, I am working in Win10.
Following is the **gulp trust-dev-cert" output:
[18:30:14] Starting gulp
[18:30:14] Starting 'trust-dev-cert'...
[18:30:14] Starting subtask 'configure-sp-build-rig'...
[18:30:14] Finished subtask 'configure-sp-build-rig' after 7.48 ms
[18:30:14] Starting subtask 'trust-cert'...
[18:30:14] Finished subtask 'trust-cert' after 79 ms
[18:30:14] Finished 'trust-dev-cert' after 90 ms
[18:30:14] ==================[ Finished ]==================
gulp trust-dev-cert must be executed IN the project folder.

Ionic2 serve not working

When i write ionic serve nothing opens. I have tried changing nodejs versions. Reinstalling ionic cordova. Also cleared cache and other ways on internet. Nothing works. Please help. No errors are shown but a window is not opened.
Info:
C:\Projects\cutePuppyPics>ionic info
cli packages: (C:\Users\Tullo\AppData\Roaming\npm\node_modules)
#ionic/cli-utils : 1.19.0
ionic (Ionic CLI) : 3.19.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
#ionic/app-scripts : 3.1.4
Cordova Platforms : none
Ionic Framework : ionic-angular 3.9.2
System:
Node : v8.9.1
npm : 5.5.1
OS : Windows 10
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
Serve:
C:\Projects\cutePuppyPics>ionic serve
Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser -
Ctrl+C to cancel
[20:52:58] watch started ...
[20:52:58] build dev started ...
[20:52:58] clean started ...
[20:52:58] clean finished in 12 ms
[20:52:58] copy started ...
[20:52:58] deeplinks started ...
[20:52:58] deeplinks finished in 40 ms
[20:52:58] transpile started ...
[20:53:03] transpile finished in 5.17 s
[20:53:03] preprocess started ...
[20:53:04] preprocess finished in 4 ms
[20:53:04] webpack started ...
[20:53:04] copy finished in 5.44 s
[20:53:13] webpack finished in 9.14 s
[20:53:13] sass started ...
[20:53:14] sass finished in 1.68 s
[20:53:14] postprocess started ...
[20:53:14] postprocess finished in 16 ms
[20:53:14] lint started ...
[20:53:14] build dev finished in 16.32 s
[20:53:14] watch ready in 16.47 s`enter code here`
[20:53:14] dev server running: http://localhost:8100/
[OK] Development server running!
Local: http://localhost:8100
External: http://192.168.10.8:8100
DevApp: cutePuppyPics#8100 on LAPTOP-NNU75MUT
Sometimes the browser doesn't open automatically. Try entering http://localhost:8100 on your browser manually after ionic serve.
force an ip adresse
ionic serve --address YOUR_IP_ADDRESS
your ip adresse should be available , i think you can use 192.168.10.8 or 127.0.0.1

Module not found: Error: Cannot resolve 'file' or 'directory' -- only on Travis

I am trying to run tests with Travis CI, but I am getting:
Module not found: Error: Cannot resolve 'file' or 'directory' ../api/Seminar in ...
I do not see this error on my local machine (Mac).
The Node version of Travis and my Mac are identical:
node v7.1.0
npm v3.10.9
Here is a larger dump of the error:
ERROR in ./~/isparta-loader!./~/vue-loader/lib/selector.js?type=script&index=0!./src/components/UpcomingSeminars.vue
Module not found: Error: Cannot resolve 'file' or 'directory' ../api/Seminar in /home/travis/build/tam5/my-app/src/components
# ./~/isparta-loader!./~/vue-loader/lib/selector.js?type=script&index=0!./src/components/UpcomingSeminars.vue 9:786-813
14 11 2016 19:50:54.546:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
14 11 2016 19:50:54.548:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
14 11 2016 19:50:54.554:INFO [launcher]: Starting browser PhantomJS
14 11 2016 19:50:54.922:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket /#IMyChahiZWxdaUeTAAAA with id 80626811
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
Error: Cannot find module "../api/Seminar"
at webpack:///src/components/UpcomingSeminars.vue?4396:9:0 <- index.js:26609
Here is my entire .travis.yml:
language: node_js
node_js:
- "7"
- "6"
How can I fix this to run on Travis as well?

"Process finished with exit code 199" is populating when run the config file

I Executed the config file, browser invoked after that the below Error is appeared in console.
Tools Used Webstrom/Eclipse
Protractor Version :4.0.0
"C:\Program Files (x86)\JetBrains\WebStorm 2016.2.3\bin\runnerw.exe"
"C:\Program Files\nodejs\node.exe"
C:\Users\surya\AppData\Roaming\npm\node_modules\protractor\built\cli.js
C:\samplepro\conf.js
I/hosted - Using the selenium server at http://localhost:4444/wd/hub
I/launcher - Running 1 instances of WebDriver
E/launcher - "process.on('uncaughtException'" error, see launcher
E/launcher - Process exited with error code 199
Process finished with exit code 199
Protractor version 4.0.0 have one important bug with uncaughtException uncaughtException after a Protractor run
You should use protractor version >4.0.1
After upgrade the protractor version you should be able to see what is the problem

Uncaught object error with Karma

I am pretty new to jasmine and karma, but I have a rails app set up using requirejs and jasmine and I'm trying to get karma up and running. I have it running, but when I run the unit.js config file, I get the following error.
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 35.0.1916 (Linux)]: Connected on socket PFOOqf9ZbOB_Tv7zhugx with id 60346244
Chrome 35.0.1916 (Linux) ERROR
Uncaught object
at /home/parallels/Code/Test/src/node_modules/requirejs/require.js:141
WARN [web-server]: 404: /people.js
WARN [web-server]: 404: /jquery.js
WARN [web-server]: 404: /page.js
WARN [web-server]: 404: /dropzone.js
Line 141 in require.js is
function defaultOnError(err) {
throw err; //<-- this is 141
}
Here is my karma unit.js config file.
// Karma configuration
// Generated on Thu Jul 10 2014 08:25:37 GMT-0400 (EDT)
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', 'requirejs'],
// list of files / patterns to load in the browser
files: [
{ pattern: 'spec/javascripts/extensions/*_spec.js', included: true },
{ pattern: 'spec/javascripts/*_spec.js', included: true }
],
// 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
});
};
I'm not sure what the problem is, but based on the 404 messages, I'm guessing it might have something to do with requirejs not being able to find those 4 javascript files. If I manually run my jasmine specs they all run fine, so I'm not quite sure where/why it's breaking down. Anyone have any ideas? Thanks.
Edit:
I have updated my code based on the karma+requireJS documentation. It seems like it's gotten me further along, but now I just get a generic error without much of a message to know what's going on.
When I run the karma test I get this....
karma start spec/karma/config/unit.js
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 35.0.1916 (Linux)]: Connected on socket OwrWtfnBJ4zB6DERU0cI with id 70596022
Chrome 35.0.1916 (Linux): Executed 0 of 0 ERROR (0.004 secs / 0 secs)
My folder structure is as follows
src
--app
----assets
------javascripts
--------application.js, global.js,page.js, routes.js, people.js, etc
--spec
----javascripts
------*_spec.js
----karma
------config
--------unit.js, test-main.js
--vendor
----assets
------javascripts
--------dropzone.js, icheck.js, jquery-ui.js, mustache.js

Resources