0

I have spent hours trying to set up an automated testing environment for my AngularJS applications that I can run from Maven (capturing results in Bamboo)

A Google search reveals frameworks galore, based on Jasmine, Karma and generic JavaScript frameworks.

But for some reason the installation of these never goes as described.

Can anyone just point me to a set of downloads that I can install manually to proper directories, that will just execute my unit tests?

I asked a similar question previously and got down checked and requests to close. If you need to check me down, please leave a reason, as I am besides myself with frustration trying to solve this, and I am sure there many other developers experiencing the same issue

2 Answers 2

1

Testing javascript is not a totally mature thing, so there isn't a great diversity of good tools for doing so. Jasmine and Karma are the current best ways of doing that.

Those tools are best managed using bower, which is a nodejs package. So you'll have to install, in this order:

  • nodejs
  • npm (node package manager)
  • bower (using npm)
  • jasmine and karma using bower
  • phantomjs, and whatever other dependencies your javascript needs (presumably angular)

Then you can run the tests.

I found this package for maven with some brief googling, but god knows how to set it up:

http://searls.github.io/jasmine-maven-plugin/

There are many tutorials on going through this process. You have to accept that these are currently the best tools for doing this and give it your best shot. If you post more specific issues regarding the 'installation that never goes as described' of jasmine and karma you will get assistance.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, I pretty much got this far, but the obstacle then is your step 5. Adding Angular as a dependency fails, because the angular scripts depend on a window object, which fails when you're not running in a browser.
Normally karmas config file handles loading modules like angular for you. Were you using Karma, and what did the config look like?
Yes, I was trying to use Karma. The Angular seed comes with karma.conf.js. From the seed root dir, I run npm install, which launches the http-server on port 8000, and I see that spinning. (localhost:8000 from a browser gives me a directory listing of my project). Then I launch a new command shell (working in Mac-Linux) and do npm run protractor. That spins for a few minutes, then reports back with a stacktrace timeout exit status=8 and an unusual message: ^ Error: Timed out waiting for the WebDriver server at 192.168.1.3:61154/wd/hub. Not sure why it is using that 61154 port
That's odd. So you are using protractor to do e2e tests and that's what webdriver is for? Did you see this question: stackoverflow.com/questions/20555953/…
1

you can use for example yeoman or angular-seed. both will require nodejs and optionally ruby. both will set you with phantomjs, jasmine, karma, bower and many more. however i would avoid combining that build with maven. imho it's far from perfect. java tools will never be as good as native js tools for building js project. if you really want to combine the builds then use java only to call nodejs and nothing more

1 Comment

I tried Yeoman, but that failed early on, during the Phantom install. I tried it on Windows 7 and Mac, both with the same result. Angular seed failed on launching Protractor

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.