Showing posts with label AngularJS. Show all posts
Showing posts with label AngularJS. Show all posts

Tuesday, March 15, 2016

When it comes across circular-dependency

Refer to Circular Dependency in constructors and Dependency Injection
I have to quote this:
To find out which one it is, list all of the methods in your class B used by class A, and all the methods in your class B used by class A. The shorter of the two lists is your hidden Class C.

Wednesday, March 9, 2016

Thursday, February 25, 2016

The black hole in localStorage.setItem()

TL;DR

To fake some local storage data in Protractor E2E test, care about 2 things:
  • localStorage can not store Object directly, so you have to JSON.stringify it and then JSON.parse to get it back.
  • browser.executeScript actually returns a Promise, so you should JSON.parse the data received by its then function.

How to mock $httpBackend in protractor

Some say this is not a good idea since end-to-end test should be genuinely END-TO-END, not END-TO-itself, ......whatever, I just need it.

My solution is based on this post, but I got 2 problems which screwed me good.

Saturday, February 20, 2016

Angular bound model data not updated in the $on callback function

TL;DR

Using $timeout or $apply, or $evalAsync in the callback function of $on, if you need to handle some bound model and have to make sure you get it before or after it's updated

I met this one when I was trying to save map data from a google map view whenever user changes the map view.

Tuesday, January 5, 2016

E2E Test - Protractor - Redirect to non-angular page

This one happens when I try to redirect browser to a non-angular web page in my e2e-test.
I got the following error message:

 Failed: Error while waiting for Protractor to sync with the page: "window.angular is undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"  


Wednesday, December 30, 2015

E2E Test - Protractor - Wait for google map markers to present

The problem is that in my e2e-test I expect markers to present on map too early before google maps api actually rendering them.

This is, or should be, an easy one, nevertheless it pained my ass because I'm a stinky newbie to Protractor.

Sunday, December 27, 2015

Unit test - Jasmine - Spied function was actually called but test result says it's never called

Today I spent entire morning to figure out WTF is going on in my unit-test.

Long story short, I spied on a function, I saw the debug log coming from the function, which means it definitely has been called, but the test result kept saying that it was never called.