Monday, May 30, 2016

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

TL;DR

Your test/spec, a single it block, spends a too damn long time to finish.
Increase the value of jasmineNodeOpts.defaultTimeoutInterval in protractor.conf.js
Or give it an additional arguments to specifically set timeout.

Wednesday, April 27, 2016

Request cancel by client

I've spent entire morning to find out which part of my server's code cause the console message below

POST /api/channels - - ms - -

This message indicates that this request has been cancelled at some point in its life cycle, since there is no elapsed time recorded.
It turns out I've been thinking in the wrong way, it's the client, not server, stupid... stupid...


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"