We have a big Angular 1.4 application. Our equally big set of E2E tests are written using Angular Scenario Runner (Yes, I know we should have used Protractor).
Now, we are trying to transition to Angular2, going through the ngUpgrade hybrid approach.
The issue is that the ngScenario tests are all failing due to bootstrapping issues. As, the bootstrapping is asynchronous for the upgradeAdapter, opposed to synchronous in Angular 1.
Please help as to what could be done ?
Related
I want Jenkins to run JavaScript unit tests.
Although I came across different JavaScript unit test frameworks, like Jasmine or Tape, I cannot find any documentation on how to make them work and set-up their output to co-operate with Jenkins.
Can anyone point me to a documentation for Jasmine, Tape and other unit test frameworks, explaining on how to configure them properly to be triggered and evaluated by Jenkins?
There is nothing special to do with regards to Jenkins. You need to install the testing libraries as you normally would on the Jenkins executor nodes, and then you can use them as you normally use them from within your Jenkins job. Note that this may mean calling npm install from within your Jenkins job - this is pretty typical; you would do something similar whether you were using Python virtualenv, Ruby bundler, etc.
Until now, I've done all my testing with just Jasmine and jQuery to automate the browser. I am starting to explore Karma but it seems to be set up only for unit tests that involve loading HTML fragments as test fixtures and I find no way to load a whole web page. Am I missing something or is this simply the wrong tool for what I am trying to do?
From the karma FAQ's section:
Can I use Karma to do end to end testing?
Karma has primarily been designed for low level (unit) testing. If it's an AngularJS app, you can use Karma with the karma-ng-scenario plugin. However, we recommend Protractor for high-level testing.
Typically, loading a whole web page goes beyond the scope of single units of code: you need to spin up a browser, load the page and make your actions and assertions. End-to-end testing frameworks like Protractor, Nightwatch.js or Webdriver.io might be more suitable for this specific case.
You can do integration testing using the following toolchain:
Karma ➔ Mocha ➔ Mocha-CasperJS ➔ CasperJS.
Check out the mocha-casperjs package.
I have some Angular/Rails app where Rails part is just JSON API, all front works is doing by AngularJS. I've made model/controller test already using RSpec, and now I want to make some integration tests. Earlier I use request test (with Capybara, Selenium) of RSpec to test my pages/JS, but Angular is often tested by Karma/Jasmine, and I don't understand what way is preferred in Angular/Rails app. Please, give me advice, may be you share some experience with me. Thanks.
First of all you should test everything wisely. I will recommend great series of blog posts from the link below.
Since you are already familiar with RSpec, keep using it for your rails tests like models, controllers, request, etc.
For your Angularjs tests, karma and Jasmine are great choices. But Rails uses Sprockets for asset management so configuring karma can be a little bit tricky. For Rails and Jasmine I wrote a rake task. To run javascript tests you should simply run rake karma:start. I shared the link of the gist below.
The gist contains 2 files. You should put them:
karma.rake -> lib/tasks
karma.unit.js -> spec/javascripts/
Finally you should run feature/acceptance tests with Capybara.
Testing Series Intro
The Gist of Rake Task and Karma Configuration
I'm trying to test my Backbone.js web application.
Since this application is basically only consuming web services, there is not really business logic inside, and the app is simply addressing calls to our API.
I'd like to use Zombie.js for ma integration test suit, which works - for the moment - with Karma and Jasmine.
My problem is I'm using RequireJS, and because Zombie doesn't seem to be AMD compliant, I can't import Zombie into my test view.
Any ideas?
Can you include zombie js in your test runner? I think karma has a files array in its config
source: http://toon.io/how-to-setup-karma-javascript-test-runner/
I am trying to choose a setup for testing a webapp that uses Backbone and RequireJS.
I will try to do most of my unit testing from javascript and I am in doubt whether it is better to load my whole app before calling the testing framework or to use RequireJS to dinamycally load just the modules that are being tested by each test.
As this site is just for Q&A and not open to discussion, I will reformulate: Do you have any strong argument against not loading the whole app upfront when unit testing?
The best way is to test each of your Models/Collections/Views separately in unit test. Starting the whole app in a unit test would it made really hard to test all cases for a module. As you mention requireJS you should also mock most of the dependencies of a module using squireJS.
But you should additionally have some integration tests where you test the behavior of the whole app in a headless browser using a tool like selenium, casperJS or capybara.
With requirejs, there are two ways for you to interpret loading upfront:
During development, where r.js is not be used, and just depend on configuration on requirejs.config
After r.js optimization, where the modules can be restructure by r.js configuration