4

I want to test my AngularJS application using Selenium and PhantomJS, but I am not finding an easy to start resource or video tutorial. Can you please suggest some good resource as a starting point.

2
  • Do you want to do unit or e2e tests? As i am into all of this at the moment, I can send you good links. Commented Feb 7, 2014 at 14:41
  • @glepretre I have to test if the website I have build is functioning properly and the flow are correct or not so i think it will be E2E testing.Please share those links. Commented Feb 10, 2014 at 6:46

2 Answers 2

3

Have you looked at this tutorial?

The tutorial itself seems decent. You might have to change some stuff depending on what you choose as your test-runner (this tutorial chose Mocha).

I'd also look at Karma and Protractor which are built by the AngularJS team. Protractor is targeted more towards end-to-end testing in AngularJS apps.

If you're set on Selenium, you could also look at Nightwatchjs which is also end-to-end and runs against a Selenium server but requires Node.js. Nightwatchjs could be compared to Protractor but seems like it has easier-to-understand syntax.

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

3 Comments

which one according to you is more suitable for unit testing and E2E testing. Is it PhantomJS or Karma. Please suggest.
i have tried the selenium and phantomjs tutorial suggested by you with the simple google.com example but got stuck while running the test script using Mocha.What will be the syntax to run that.Really I got stuck very badly.
I'd suggest Karma simply because it's primarily made for AngularJS so it fits really nice. The AngularJS team has been improving their documentation so at least you may find it easier to set up your work than it would be before. There are some tutorials - karma-runner & this one touches on PhantomJS as well - on how to use Karma and Jasmine together for testing purposes. I don't know how much you know about TDD but Jasmine promotes a BDD style testing which is a subset of TDD.
2

As @Nima-Vaziri said, you should have a look at Karma to run unit tests on your app. This article will help you on this way.

Then to run e2e tests, the new runner developped by the Angular team is Protractor and you can start with this demo : Protractor demo

To understand, these docs were very useful to me:

If you're going to work with AngularJS: you definitely should know about eggehead.io videos! This one is about Protractor. But, there's a lot of video tutorials very interesting to teach you how to build an Angular app!

Comments

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.