4

I am working on an application that has been written in AngularJS. I only recently joined this company, so was not involved in the design or writing of the application as it currently stands.

The development team are looking to integrate automated testing into the development methodology/ life cycle, and I have been given the task of researching testing frameworks that we could look to implement/ use with our code.

I have been following the Jasmine/ Karma tutorial at https://scotch.io/tutorials/testing-angularjs-with-jasmine-and-karma-part-2, for setting up Jasmine/ Karma as the testing suite for an AngularJS app, and while it does seem to provide some useful tools/ methods for testing the code, and could certainly be useful, I haven't come across anything in the tutorial that indicates that it's possible to use this framework to simulate user interaction with the front end, and test the application's responses to user interaction... which is what we are specifically looking to automate.

All of the tests that the tutorial runs through with you seem to be for testing the logic of the code written- none of them seem to test for user interaction with the front end (the web elements).

The reason we're looking to automate this testing is because as we add new features/ fix bugs & role the versions out to our customers, we will need to test everything on the front end every time, to ensure that none of the changes we've made have broken anything that our clients are using/ will need to use. It would save us a huge amount of time and effort if we could just run a batch of scripts against every version of the software we release, to test all of the front end elements that haven't changed between versions.

Is there a way that I could use Jasmine/ Karma to do this, or is there another tool that would be better suited to specifically testing the user interaction with the application?

1 Answer 1

3

Jasmine+Karma combination is typically used for unit testing of a JavaScript application.

But, you are describing tests that involve user interactions which suggests an end-to-end testing tool. And, there is one that was made specifically for AngularJS applications (even though the app does not have to be AngularJS based for it) - Protractor.

Protractor is basically a convenient, feature-rich wrapper around WebDriverJS - javascript selenium bindings. One of the things that make it unique is that it has that "synchronization" ensured between Protractor and Angular during test lifetime of your tests. It helps to, most of the times, avoid adding extra waits inside your tests. On top of that, there are multiple AngularJS specific locators, like by.model or by.repeater that you can use to locate elements on a page.

5
  • Thanks for your answer. I'm looking into installing & running Protractor, following the tutorial at: protractortest.org/#/tutorial, but have come across an issue during the setup- the guide says to install Protractor with npm install -g protractor, which I've done (protractor --version shows "Version 5.1.2), I then ran the update command, and then tried running the start command, but this gave me output that says: 'java' is not recognized as an internal or external command, operable program or batch file. [11:24:04] I/start - Selenium Standalone has exited with code 1 Commented Sep 20, 2017 at 11:25
  • I have Java installed, so I'm not sure why I'm getting that error... any suggestions? Commented Sep 20, 2017 at 11:26
  • 1
    @someone2088 let's try to stay in the scope of the question you've asked and avoid solving follow-up problems in comments. You can consider asking as separate question if you have difficulties configuring protractor, though I am pretty sure this particular problem is googlable. Thanks for understanding.
    – alecxe
    Commented Sep 20, 2017 at 13:15
  • Sure, thanks for the tip on Protractor- seems that it will do what I need. Commented Sep 20, 2017 at 14:50
  • 1
    @someone2088 - One catch is that (AFAIK) the only language you can use is JavaScript. So if for some reason you want to use different development language, you have some hard decisions to make. Our main language is Python, and being able to call Python libraries to trigger some deep system functionality is crucial for us. But if you are ok with being restricted to JS, protractor is fine (and "standard") choice. Commented Sep 20, 2017 at 15:05

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.