UT/E2E test with route?

Showing 1-15 of 15 messages
UT/E2E test with route? Xi Shen 12/9/12 6:03 AM
Hi,

I am wondering if there's a way to test the route behavior using unit test, or E2E test. I am using Testacular and ngScenario.

I tried "browser().navigateTo('/mytest')", and the in the browser console, I see ngScenario is really trying to load that URl, and got a 404 error, because I did not start my web server. But I think starting my web server won't help here. I want to know if the URL is handled by NG, and if my controller is called, or the "$routeChangeSuccess" event is triggered.

Any idea how to implement this?


Thanks,
David.

Re: [AngularJS] UT/E2E test with route? Pete Bacon Darwin 12/9/12 6:55 AM

E2e tests rely on a host serving up your files. It is end to end after all!

Pete
...from my mobile.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
 
 
Re: [AngularJS] UT/E2E test with route? Xi Shen 12/9/12 7:09 AM
well...that makes sense. ;P
Re: [AngularJS] UT/E2E test with route? Yevgeniy Valeyev 12/10/12 3:16 AM
Is there a way to create a unit test for route? 

воскресенье, 9 декабря 2012 г., 16:55:53 UTC+2 пользователь Peter Bacon Darwin написал:
Re: [AngularJS] UT/E2E test with route? Pete Bacon Darwin 12/10/12 4:48 AM
What is it about the route that you want to test?
Re: [AngularJS] UT/E2E test with route? Yevgeniy Valeyev 12/10/12 4:56 AM
I want to test if router passes params into controller correctly (Such weird task).(in unit test)

понедельник, 10 декабря 2012 г., 14:48:07 UTC+2 пользователь Peter Bacon Darwin написал:
Re: [AngularJS] UT/E2E test with route? Pawel Kozlowski 12/10/12 4:59 AM
Hi!

On Mon, Dec 10, 2012 at 1:56 PM, Yevgeniy Valeyev
<webmas...@gmail.com> wrote:
> I want to test if router passes params into controller correctly (Such weird
> task).(in unit test)

Hmm, are you talking about the 'resolve' property of the route
definition? If so this probably shouldn't be tested in the unit test
(you would be testing the framework in this case). Inside e2e tests
you also wouldn't test it explicitly, as you would verify effect
through UI.

Could you share some code to illustrate what you mean exactly by
"router passes params into controller"?

Cheers,
Pawel

--
Question? Send a fiddle
(http://jsfiddle.net/pkozlowski_opensource/Q2NpJ/) or a plunk
(http://plnkr.co/)
Need help with jsFiddle? Check this:
http://pkozlowskios.wordpress.com/2012/08/12/using-jsfiddle-with-angularjs/

Looking for UI widget library for AngularJS? Here you go:
http://angular-ui.github.com/
Re: [AngularJS] UT/E2E test with route? Yevgeniy Valeyev 12/10/12 5:14 AM

Something like that :) http://jsfiddle.net/ujeen/2J9su/

понедельник, 10 декабря 2012 г., 14:59:25 UTC+2 пользователь Pawel Kozlowski написал:
Re: [AngularJS] UT/E2E test with route? Pawel Kozlowski 12/10/12 5:16 AM
Hey,

I was after the code you are trying to test...
How the AtomDetailsCtrl looks like?

Cheers,
Pawel

On Mon, Dec 10, 2012 at 2:14 PM, Yevgeniy Valeyev
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to
> angular+u...@googlegroups.com.
> Visit this group at http://groups.google.com/group/angular?hl=en-US.
>
>



Re: [AngularJS] UT/E2E test with route? Yevgeniy Valeyev 12/10/12 5:30 AM
It seems simple but I don't know how
http://jsfiddle.net/ujeen/N5ZtL/2/

понедельник, 10 декабря 2012 г., 15:16:16 UTC+2 пользователь Pawel Kozlowski написал:
Re: [AngularJS] UT/E2E test with route? Pawel Kozlowski 12/10/12 5:36 AM
Hey,

The only thing that your controller does atm is this:
$scope.route = $routeParams;

and you could test it (from to of my head):

expect(scope.route).toBeDefined();

The bottom line is that you should be testing only _your_ code and not
the framework internals.

I guess it doesn't address all of your concerns so come back when
you've got more code in your controller.

Cheers,
Pawel


On Mon, Dec 10, 2012 at 2:30 PM, Yevgeniy Valeyev
Re: [AngularJS] UT/E2E test with route? Pete Bacon Darwin 12/10/12 5:36 AM
If you want to "unit" test the controller then you should mock up the $routeParams in your test.
If you want to test that the $routeParams are correct for different urls then you can set the current url using $location and then check what the $routeParams are.
Pete
Re: [AngularJS] UT/E2E test with route? Yevgeniy Valeyev 12/10/12 5:41 AM
great, thanks

понедельник, 10 декабря 2012 г., 15:36:46 UTC+2 пользователь Peter Bacon Darwin написал:
Re: [AngularJS] UT/E2E test with route? Xi Shen 12/10/12 7:10 AM
Directly test the $routeParams is really good idea. :) 
Re: [AngularJS] UT/E2E test with route? Xi Shen 12/23/12 3:49 AM
Hi all,

I did not have time to try out this idea. But it seems it does not work for me :( Here's my code:

describe('ng route', function () {
  var $injector = angular.injector();

  beforeEach(module('blog'));

  it('should route to /blog/admin', inject(function ($route, $routeParams, $location) {
    $location.path('/blog/admin');

    dump($route);
    dump($routeParams);
  }));
});

in the console, the dump for $route is all the routes I defined; but the dump for $routeParams is an empty object.

@Peter, I am not sure if I understand you correctly. Please correct me.


Thanks,
David