I use this yeoman generator: https://github.com/Swiip/generator-gulp-angular
It installs three testing applications: Jasmine, Karma , Protractor According to this article (Should I be using Protractor or Karma for my end-to-end testing?), I should use: Karma for small tests of e.g. a single controller. Protactor if I want to test the whole app and simulate an user browsing through my app. According to this blog (http://andyshora.com/unit-testing-best-practices-angularjs.html) I would use Jasmine for unit testing and Karma for end-to-end integration tests.
I guess Jasmine is the language where tests are written and the other two execute the code, is that correct? Also if I never wrote a test which is more important to learn first/ to focus on?
Jasmine and Karma are usually used together to perform Unit testing or integration testing. Protractor is an end-to-end test framework for Angular and AngularJS applications.
Yes, you can use karma and protractor together. Karma is used for unit testing the component you created using angular command you can test those components using karma. Protractor is used for end to end test.
When do I use which? Karma is a great tool for unit testing, and Protractor is intended for end to end or integration testing. This means that small tests for the logic of your individual controllers, directives, and services should be run using Karma.
Karma is a test-runner, so it runs your test. Jasmine is the framework that let you write test
In my opinion in Angularjs you :
Protractor is made for E2E testing (tests navigation like a real user). It combines WebDriverJS with Jasmine and lets you write End-to-End tests (you simulate a real browser and taking real actions) with Jasmine syntax.
That kind of test is also really important in a web app.
You should not test everything, especially at the start of the project, those kinds of tests usually come with a high level of maintenance (i.e., when you change a screen you may have to change the test).
What I do is test the critical path and features. I made a reading app, so in my case, it was login, sign up, payment, access book, and access reader.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With