angular in zombie

1,308 views
Skip to first unread message

Tamas Herman

unread,
Jan 10, 2012, 4:35:00 PM1/10/12
to ang...@googlegroups.com
guys,

im trying angualr from the zombie v0.12.11 headless browser running in node v0.6.6

B = require('zombie')
b = new B
b.visit('http://127.0.0.1:8001/', { debug: true}, function(e, b){console.log(b.html())})

the index.html under this url is served via express and it does work in chrome for example, but in zombie, i can't see the {{…}} templates processed.

is there any special treatment required to run angular in zombie?
am i missing something?

--
tom

ps: here is my index.html

<!doctype html>
<html xmlns:ng="http://angularjs.org">
<head>
<script src="http://code.angularjs.org/0.9.19/angular-0.9.19.min.js" ng:autobind></script>
<script>
AppController.$inject = ['$xhr']
function AppController ($xhr) {
var that = this
this.$xhr = $xhr;
this.$xhr.defaults.headers.post['Content-Type']='application/json';
this.firms = {}
this.firm_cnt = Object.keys(this.firms).length
$xhr('GET', '/firms', function(code, res) { that.firms = res })
}
</script>
</head>
<body >
<div ng:controller="AppController">
{{firm_cnt}} Firms: <span ng:repeat="firm in firms">{{firm}}, </span>
</div>
</body>
</html>


Misko Hevery

unread,
Jan 10, 2012, 8:36:03 PM1/10/12
to ang...@googlegroups.com
My understanding of zombie.js is that it is emulation of the browser and not the real browser. So chances are that their emulation is different enough such that the angular runs into some issue and fails to boot.

What exactly are you trying to test? Have you tried the unit tests? Scenario runner?

-- Misko





--
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.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.


Tamas Herman

unread,
Jan 19, 2012, 12:34:44 PM1/19/12
to ang...@googlegroups.com
On Wednesday, January 11, 2012 at 8:36 AM, Misko Hevery wrote:
> My understanding of zombie.js is that it is emulation of the browser and not the real browser. So chances are that their emulation is different enough such that the angular runs into some issue and fails to boot.
> What exactly are you trying to test? Have you tried the unit tests? Scenario runner?

i should try those 1st, indeed…

but what i tried instead is http://www.phantomjs.org (http://www.phantomjs.org/)/
another webkit based headless browser and
it gave a perfect, pdf printout for my request for quotation (using angular 0.9.19)
with all the background colors (black and silver :) *by default*!
no tedious config required!
just try it for yourself:

curl -O http://phantomjs.googlecode.com/files/phantomjs-1.4.1-macosx-static-x86.zip
unzip phantom*zip
cd phantom*/
time bin/phantomjs examples/rasterize.js http://google.com google.pdf a4; open google.pdf

real 0m5.933s
user 0m1.174s
sys 0m0.427s

--
tom


Suller Andras

unread,
Jun 13, 2012, 11:05:34 AM6/13/12
to ang...@googlegroups.com
Hi guys,

I tried zombie 1.3.1 in node 0.6.10 with angular 1.0rc12.
It has a problem with routing. When I tried to run the angular-seed
app in zombie, I got:

Error: 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["fn: $locationWatch;
newVal: 8; oldVal: 7"],["fn: $locationWatch; newVal: 9; oldVal:
8"],["fn: $locationWatch; newVal: 10; oldVal: 9"],["fn:
$locationWatch; newVal: 11; oldVal: 10"],["fn: $locationWatch; newVal:
12; oldVal: 11"]]

It turned out that Angular stores window.location attribute in the
$browser service, and it seems zombie replaces this object with a new
one sometimes, so Angular could not get the current location. I added
a "location = window.location;" statement to the beginning of
$browser.url method and this issue went away.

Is this is an Angular issue or a zombie issue?

I tried with angular 1.0rc10, the result is the same:
Error: 10 $digest() iterations reached. Aborting!

Andras

ni...@bitcasa.com

unread,
Jun 14, 2012, 8:47:51 PM6/14/12
to ang...@googlegroups.com
I haven't used zombie, but that error is very familiar.  I reported a few issues that cause that exact error scenario.

Vojta Jína

unread,
Jun 26, 2012, 1:05:32 AM6/26/12
to ang...@googlegroups.com
Angular keeps reference on location.
It looks like zombie create new instance of location.

I guess zombie should behave the same as browsers do and they don't create new instance of location. It's still the same object. So that sounds like problem of zombie.
However, I think it wouldn't hurt if Angular always does location = window.location, as you described.

V.
Reply all
Reply to author
Forward
0 new messages