Webstorm Karma Test Runner Not Working with Yeoman angular-fullstack - javascript

I created a web application using the Yeoman Angular-Fullstack generator. Everything runs correctly from the command line. I can use grunt to start the service and run tests.
I want to run the Karma unit tests inside the Webstorm user interface. I right clicked on karma.conf.js and had Webstorm create a Karma run configuration for me. When I try to run that configuration, it spins for a few seconds then fails.
The Karma Server window in Webstorm contains this:
/usr/local/bin/node /Applications/WebStorm.app/Contents/plugins/js-karma/js_reporter/karma-intellij/lib/intellijServer.js --karmaPackageDir=/Users/williammcneill/Documents/Work/LearnNode/gecko/node_modules/karma --configFile=/Users/williammcneill/Documents/Work/LearnNode/gecko/karma.conf.js
WARN [watcher]: Pattern "/Users/williammcneill/Documents/Work/LearnNode/gecko/client/bower_components/angular-route/angular-route.js" does not match any file.
WARN [watcher]: Pattern "/Users/williammcneill/Documents/Work/LearnNode/gecko/client/app/app.coffee" does not match any file.
WARN [watcher]: Pattern "/Users/williammcneill/Documents/Work/LearnNode/gecko/client/components/**/*.coffee" does not match any file.
WARN [watcher]: Pattern "/Users/williammcneill/Documents/Work/LearnNode/gecko/client/components/**/*.jade" does not match any file.
WARN [watcher]: Pattern "/Users/williammcneill/Documents/Work/LearnNode/gecko/client/app/**/*.coffee" does not match any file.
WARN [watcher]: Pattern "/Users/williammcneill/Documents/Work/LearnNode/gecko/client/app/**/*.jade" does not match any file.
INFO [karma]: Karma v0.12.37 server started at http://localhost:8080/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.8 (Mac OS X 0.0.0)]: Connected on socket 29_J57vgWL6mWwyV13tv with id 98142631
Which all looks correct to me. The Test Run window contains this:
/usr/local/bin/node /Applications/WebStorm.app/Contents/plugins/js-karma/js_reporter/karma-intellij/lib/intellijRunner.js --karmaPackageDir=/Users/williammcneill/Documents/Work/LearnNode/gecko/node_modules/karma --serverPort=8080 --urlRoot=/
/Applications/WebStorm.app/Contents/plugins/js-karma/js_reporter/karma-intellij/lib/intellijRunner.js:54
throw e;
^
Error: connect ETIMEDOUT 127.0.0.1:8080
at Object.exports._errnoException (util.js:837:11)
at exports._exceptionWithHostPort (util.js:860:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1060:14)
Process finished with exit code 1
I can't figure out what is timing out. If I open http://localhost:8080 I see a webpage that looks like this.
Which also looks correct to me.
I haven't actually written any code. I'm taking all the defaults that Yeoman and Webstorm give me. I think I have all the relevant Webstorm plugins (AngularJs, Karma).
Does anyone have insight into what might be happening or how I could debug it?
Webstorm 10.0.4, Yeoman 1.4.8, Karma 0.13.9, Node 4.1.0, OS X 10.10.5

The port value in karma.conf.js is set to 8080, even though the server runs on 9000. Change this value to 9000 and everything works.
Not sure exactly how the grunt configuration makes it all work, or why it's set up this way, but that's the workaround.

Related

Gulp-plumber not found in Ubuntu OS, but found in Windows OS on dual boot

I am following a tutorial, and I am supposed to have a gulpfile.js running, but I'm encountering a strange situation. Gulp works in one location and does not work in the other.
I have a dual boot for Ubuntu and Windows 8.1. In the Ubuntu OS Documents directory the gulp command does not work, but returns an error saying "'gulp-plumber' not found". I don't understand why since the folder structure is exactly the same. If I change directory to the windows volume and access the main project folder, when I type "gulp" everything works fine.
Additionally, if I CTRL-C in the command line, the gulp command stops working and returns an error saying:
events.js:163
throw er; // Unhandled 'error' event
Error: write EPIPE
So how can I run the gulp command again? Is it through ps aux, check something running and then kill it?
github.com/DannyS95/Project
This issue has been fixed, i had to install gulp plumber, because i did not have that package in the package.json file.
Then a quick npm install, and since i have gulp globally i can just run gulp and voila, it works.

Karma testing adding unnecessary folders to path

I'm trying to do some unit testing and I'm at the end of my rope. I've moved files, rewritten things countless times, and I still can't get the damn thing to work. I've followed this tutorial exactly and it still doesn't work.
When I run "gulp tests", and I am in my ~/git/mobile directory, I get the following output
Josh#DAEDALUS ~/git/mobile (unit-testing)
$ gulp test
[10:28:40] Using gulpfile c:\Users\Josh\git\mobile\gulpfile.js
[10:28:40] Starting 'test'...
WARN [watcher]: Pattern "c:/Users/Josh/git/mobile/tests/www/lib/angular/angular.
js" does not match any file.
WARN [watcher]: Pattern "c:/Users/Josh/git/mobile/tests/node_modules/angular-moc
ks/angular-mocks.js" does not match any file.
WARN [watcher]: Pattern "c:/Users/Josh/git/mobile/tests/www/js/app.js" does not
match any file.
WARN [watcher]: Pattern "c:/Users/Josh/git/mobile/tests/www/js/controller.js" do
es not match any file.
WARN [watcher]: Pattern "c:/Users/Josh/git/mobile/tests/www/js/services.js" does
not match any file.
WARN [watcher]: Pattern "c:/Users/Josh/git/mobile/tests/tests/Controllers/contro
llers.tests.js" does not match any file.
WARN [watcher]: Pattern "c:/Users/Josh/git/mobile/tests/tests/Services/services.
tests.js" does not match any file.
INFO [karma]: Karma v0.12.37 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.8 (Windows 8 0.0.0)]: Connected on socket --QoOiVt0ZraOpiQ3q
zd with id 22369565
PhantomJS 1.9.8 (Windows 8 0.0.0): Executed 0 of 0 ERROR (0.003 secs / 0 secs)
[10:28:42] Finished 'test' after 2.19 s
See, I don't get why it decides that it wants to add the /tests/ folder out of nowhere. It's not in my directory. For example, a proper path would be c:/users/josh/git/mobile/www/js/controller.js That tests folder isn't there. There is a tests folder in my mobile directory, but it doesn't contain anything but my "my.conf.js" and two subdirectories which contain my test files.
I cannot for the life of me figure out what's wrong. I've tried adding ../, ./, /, or removing that all together from the beginning of my files paths in my.conf.js.
Here is the contents of "my.conf.js"
Here is the contents of "gulpfile.js"
I fixed this by adding ../ to my basePath.

Karma "not found" in NetBeans after upgrading to Yosemite

I have a WAR project in NetBeans which uses Karma with Jasmine to unit-test the JavaScript files. The platform is Mac OS X. Things worked as they should under Mavericks, but after I upgraded to Yosemite, it no longer works, with the error message :
Failed to execute goal com.kelveden:maven-karma-plugin:1.8:start (default) on project Insight-war: There was an error executing Karma. Cannot run program "karma" (in directory "/Users/thja/Documents/Projects/kpi2010_core/WebGIS/Insight-war"): error=2, No such file or directory -> [Help 1]
It tries to execute the following command, as printed in the log:
karma start /Users/thja/Documents/Projects/kpi2010_core/WebGIS/Insight-war/src/main/webapp/config/karma.conf.js --browsers PhantomJS --reporters dots,junit --single-run --no-auto-watch --colors true
I can run the exact same command in the Terminal without a problem - it executes and give the test results. which karma gives the result /usr/local/bin/karma, and /usr/local/bin is part of the global PATH.
Is there any fix one can do for this, or do I just have to post an issue at the Maven Karma Plugin page?
Platform:
Mac OS X 10.10 Yosemite.
NetBeans 8.0.1
maven-karma-plugin 1.8
Java 1.7.0_45
It seems to be related to Yosemite turning off /etc/launchd.conf, so NetBeans doesn't get the correct PATH variable - so not directly related to Karma.
I fixed it by setting PATH=${PATH}:/usr/local/bin in netbeans.conf (within the NetBeans app package). Then the karma part of the build script runs successfully within NetBeans.

Not found error on browser after sails lift,

I am creating a new app with "sails new" command. Upon running sails lift, I am getting a "Not Found"(404) error on the browser. I have sails installed locally & here are my node & sails version info
vsnag#like:~/sails/node_modules$ sails --version
0.10.5
vsnag#like:~/sails/node_modules$ node --version
v0.10.32
The sails lift with verbose options gives me this
vsnag#like:~/sails/app$ sails lift --verbose
info: Starting app...
warn: Cannot read package.json in the current directory (/home/vsnag/sails/app)
warn: Are you sure this is a Sails app?
warn:
warn: The package.json in the current directory does not list Sails as a dependency...
warn: Are you sure `/home/vsnag/sails/app` is a Sails app?
warn:
verbose: Setting Node environment...
verbose: Please run `npm install coffee-script` to use coffescript (skipping for now)
verbose: moduleloader hook loaded successfully.
......
....
error:
------------------------------------------------------------------------
grunt-cli: The grunt command line interface. (v0.1.13)
Fatal error: Unable to find local grunt.
If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:
http://gruntjs.com/getting-started
error: Looks like a Grunt error occurred--
error: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
error: Or if you're stuck, check out the troubleshooting tips below.
......
...
verbose: Sending 404 ("Not Found") response
verbose: res.notFound() :: Could not locate view for error page (sending JSON instead). Details: Could not render view "404". Tried locating view file # "/home/vsnag/sails/app/views/404". Layout configured as "layout.ejs", so tried using layout # "/home/vsnag/sails/app/views/layout.ejs")
I tried the solution suggested in this so post, but of no use.
When I compare the anatomy of a sails App mentioned in sails docs & my app they don't seem to match
vsnag#like:~/sails/app$ ls -la
total 20
drwxrwxr-x 5 vsnag vsnag 4096 Oct 9 21:36 .
drwxrwxr-x 4 vsnag vsnag 4096 Oct 10 18:54 ..
drwxrwxr-x 7 vsnag vsnag 4096 Oct 9 21:36 api
drwxrwxr-x 4 vsnag vsnag 4096 Oct 9 21:36 config
drwxrwxr-x 2 vsnag vsnag 4096 Oct 9 21:36 views
I am missing the Gruntfile.js, README, app.js, .gitignore, package.json, .sailsrc files.
Any suggestions what might be the problem? or any setting that I am missing...
make a empty new sails app (in your home-folder) with:
$> sails new myapp
than copy your api, views and config in this "myapp"-folder and run sails lift again
Check your importer.less
I accidently included something that is not in there (a missing folder) and after fixing it, it worked. (:
If it doesn't check your pipeline.js to see if you have injected the correct files.
I was running the sails new command with npm because I installed it locally instead of globally. I got the not found and a 404. When I installed it globally, it worked.
For me I was not inside project folder,
After creating news sails project
cd into project folder
eg:
> sail new todo-app
> cd todo-app
Then run sails lift

Running Karma tests with google maps module dependency

So i included this module into my Angular app https://github.com/angular-ui/angular-google-maps
Now the question is: How to I run Karma tests that integrate it?
Running "karma:unit" (karma) task
INFO [karma]: Karma v0.10.6 server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
WARN [watcher]: Pattern "/Users/Work/status/test/mock/**/*.js" does not match any file.
INFO [Chrome 31.0.1650 (Mac OS X 10.8.4)]: Connected on socket iLYLgPcHaw8HVJjNNafq
Chrome 31.0.1650 (Mac OS X 10.8.4) ERROR
Uncaught ReferenceError: google is not defined
at /Users/Work/status/app/scripts/angular-google-maps.min.js:6
Chrome 31.0.1650 (Mac OS X 10.8.4): Executed 0 of 0 ERROR (0.509 secs / 0 secs)
Warning: Task "karma:unit" failed. Used --force, continuing.
Done, but with warnings.
So it is the global google object that is missing
I see a couple of solutions but do not know how to implement them:
-Inject the google script everytime we run tests (although inefficient). Question is, how and where do I inject it?
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=en"></script>
-i read a suggestion somewhere that we could mock the google API
This has been asked a few times already in the issues list on the project. Here is one of the q/a.
https://github.com/angular-ui/angular-google-maps/issues/270

Categories