unit testing of AngularJS code deployed under JBoss 7.1EAP - angularjs

We all know that one of the best combination for Unit testing for AngularJS code is NodeJS, Jasmine and Karma js framework .
However challenge with our project is that client doesn’t want to use two containers i.e. NodeJS for testing and Jboss for deployment. Reason is the way Angular JS components are packaged for nodeJS is very different from Jboss. Also another angle to this problem is that angular components should be tested in a continuous integration environment. If you have two containers it makes whole CI/CD cycle complex.
Hence we are trying to find out a way on to how to execute these unit test cases with only Jasmine with JBoss 7.1EAP. And without using Nodes and Karma.
Please let us know if someone has faced this issue and let us know the steps for the resolution.
Regards
Debashish

Related

What can I use for mock fetch-requests while e2e testing in protractor similar to addMockModule without Angular

I am writing e2e test with protractor for a typescript module. I want to use protractor for the additional features in comparison to selenium webdriver. I am using typescript standalone so I am building a non-angular application.
I searched a lot for mocking services or fetchmock etc. But I think I am searching at the wrong place. Maybe I just didn't understood what do I really need for my problem.
At the moment I have an application where I want to test the frontend. My problem is, that the application only works with a server which is setting up many data and make it available for rest. Without this server my javascript file wont work and I wont start the server for my tests, it must be server independent.
For example: my server provide the data on a specific address 192.168.1.230 and I can fetch the data with fetch api over: 192.168.1.230/users/1.
In unit tests I have mocked my fetches, but in e2e tests I need to mock the address (maybe with selenium webdriver) and want to get a dummy response if my api is fetching this data.
How can I realise that? I use protractor with npm (nodejs) and could need a npm plugin for this.
I saw another post here with the addMockModule, but this is only for angular modules and I don't use angular.

d3 Automation Testing

I need to test some d3 based Angular components and had thought to use Selenium IDE or Kantu, but it seems that these tools cannot record interactions with SVG elements. Are there any tools that would allow me test in this way? Or will I need to rethink the problem and use a different type of testing?
There is a tool specifically made for UI testing of angular.js pages. It's called protractor . In this, test scripts have to be written in Javascript. Protractor is for end-to-end testing.
If you are going to do unit testing , then the gold standard for unit testing angular code is Karma. Karma was created and is maintained by the core Angular team and provides many utilities that make it easy to test angular apps.
A combination of both protractor and karma can completely cover an angular app functionality.

Typescript angular and yeoman

What is a best way to kik start a project of angular and Typescript ?
Should I us the official yo angular and add on it
or is it a good stable generator that will help me with the inertial kikstart
We are currently developing with a friend a Typescript + Angular + Express generator for Yeoman :
https://github.com/NovaeWorkshop/nova
It is still under heavy development but already works and we use it to develop a real production website for a client.
It is a port from a previous great Yeoman generator Bangular where we added Typescript, UI Router and Desktop builds with Electron (Atom shell).
At the moment tests are broken and documentation is not up to date, but it's gonna come back real soon, and we would be happy to have your feedback on it.
Not sure yo is a great tool for scaffolding angular. It wants to put controllers in a controller directory and services in a service directory.
This structure is fine, but there are other structures that may serve you better. There are feature and component structures that group related controllers and services together.
You are going to want to define your services and controllers as classes with Typescript. It is always the best to register your controller with Angular is PascalCase because a unique class instance is returned. Services should be registered as camelCase as only a singleton instance Is returned.
I would recommend looking up Basarat's Angular with Typescript examples and John Papa Angular style guide.

Scala Play with Angular and Protractor project setup

I'm going to setup a new project with Scala Play on the one and angular/protractor on the other side. I could use sbt-web to load my js assets, but what is with testing?
Is there a best practice to integrate Angular into the Play framework without losing benefits like automated testing by using yeoman? Or is it better to make two projects and use gulp proxy in development?

PhantomJS integration testing with angular against live backend

I am trying to make my e2e test environment to be like the actual production environment. I discovered that when I take out the ngMockE2E from my app and run tests that actually hit the backend server then all my tests in PhantomJS fail. In all other browsers tests always pass.
I'm not sure what the cause of this is. All I know is that when I put the ngMockE2E back in then all tests pass in PhantomJS and when I take it out the tests that depend on the xhttp request fail.
One more thing the live backend is cross origin. But like I said it works fine in all other browsers. I'm wondering if PhantomJS doesn't have cors support.
Does anyone know how to remedy this? Am I supposed to always use the mocks?
For E2E testing with a real back end, I would consider using Protractor. As far as I know, ngMock and ngMockE2E are both made to fake a connection to a real server. With these libraries you can unit test your Angular project so that it works isolated.
Note that it is a bit more work to setup E2E testing with Protractor if you start from scratch. There are however also starter projects (Yeoman), which already have this setup for you. You could use generator-angular-gulp for example for your application, or you could have a look how they have set things up.

Resources