Does Zombie's "hello world" example work?

233 views
Skip to first unread message

robot1125

unread,
Aug 11, 2012, 8:32:14 AM8/11/12
to zomb...@googlegroups.com
By "hello world" example, I mean the generic app at the top of the main doc page.

I typed in the app text and only made one change - I modified the port to 3001 since 3000 is already in use on my system.  Thus I have this:

var Browser = require("zombie");
var assert = require("assert"); 

// Load the page from localhost
browser = new Browser()
browser.visit("http://localhost:3001/", function() { 

  // Fill email, password and submit form
  browser.
    fill("email", "zom...@underworld.dead").
    fill("password", "eat-the-living").
    pressButton("Sign Me Up!", function() { 

      // Form submitted, new page loaded.
      assert.ok(browser.success);
      assert.equal(browser.text("title"), "Welcome To Brains Depot"); 

    }) 

});

The docs don't show an example form, so I used this:

<html>
<head>
        <title>Brains Depot Login</title>
</head>
<body>
        <form method="post">
                Email: <input name="email" /><br />
                Password: <input name="password" type="password" /><br />
                <input type="submit" value="Sign Me Up!" />
        </form>
</body>
</html>


In a browser, you see this:

When you submit the form, you see this:

So the form itself is working.  Yet when I run the zombie app, I get this:

/home/shane/node_modules/zombie/lib/zombie/forms.js:111
  return this.ownerDocument.parentWindow.browser.dispatchEvent(this, event);
                                                 ^
TypeError: Cannot call method 'dispatchEvent' of undefined
    at Object.HTML.HTMLFormElement._dispatchSubmitEvent (/home/shane/node_modules/zombie/lib/zombie/forms.js:111:50)
    at Object.HTML.HTMLInputElement._eventDefaults.click (/home/shane/node_modules/zombie/lib/zombie/forms.js:136:23)
    at Object.define.proto.dispatchEvent (/home/shane/node_modules/zombie/node_modules/jsdom/lib/jsdom/level2/html.js:480:48)
    at EventLoop.dispatch (/home/shane/node_modules/zombie/lib/zombie/eventloop.js:135:40)
    at Object.Windows._create.window._evaluate (/home/shane/node_modules/zombie/lib/zombie/windows.js:271:23)
    at EventLoop.dispatch (/home/shane/node_modules/zombie/lib/zombie/eventloop.js:134:14)
    at EventLoop.perform (/home/shane/node_modules/zombie/lib/zombie/eventloop.js:120:5)
    at EventLoop.dispatch (/home/shane/node_modules/zombie/lib/zombie/eventloop.js:131:10)
    at Browser.dispatchEvent (/home/shane/node_modules/zombie/lib/zombie/browser.js:206:28)
    at Browser.fire (/home/shane/node_modules/zombie/lib/zombie/browser.js:201:10)

I see the GET request at the server (also when zombie debugging is enabled: "Zombie: GET http://localhost:3001/ => 200"), so I know zombie got the page with the form.

Any idea what I'm doing wrong? 
Reply all
Reply to author
Forward
0 new messages