与Behat和Mink的Zombie.js

I've been having problem after problem with getting Behat to work with Zombie.js. The problem I've got now is actually within the Zombie.js module (before, the errors were in the link between the two).

The error looks like so.

  [RuntimeException]                                                                                                                                   
  Server process has been terminated: (8) [                                                                                                            
  url.js:107                                                                                                                                           
      throw new TypeError("Parameter 'url' must be a string, not " + typeof url)                                                                       
            ^                                                                                                                                          
  TypeError: Parameter 'url' must be a string, not undefined                                                                                           
      at Url.parse (url.js:107:11)                                                                                                                     
      at urlParse (url.js:101:5)                                                                                                                       
      at Object.urlResolve [as resolve] (url.js:405:10)                                                                                                
      at History._resolve (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/history.coffee:201:20)                                         
      at History._assign (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/history.coffee:209:18)                                          
      at /Users/nathanielh/www/website/node_modules/zombie/lib/zombie/browser.coffee:326:30                                                            
      at Browser.withOptions (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/browser.coffee:105:14)                                      
      at Browser.visit (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/browser.coffee:320:12)                                            
      at Socket.eval (eval at <anonymous> (/private/var/folders/fv/fp4xrfnx7kzfq2bqzywq5p9w00010f/T/mink_nodejs_serverSZBH0W:43:10), <anonymous>:2:9)  
      at Socket.<anonymous> (/private/var/folders/fv/fp4xrfnx7kzfq2bqzywq5p9w00010f/T/mink_nodejs_serverSZBH0W:43:5)                                   
  ]                                                                                                                                                    

I've found that in history.coffee, the resolve function is trying to use an array element that doesn't exist.

  // history.coffee
  _resolve: (url)->
    if url
      return URL.resolve(@_stack[@_index]?.url, url)
    else # Yes, this could happen
  return @_stack[@_index]?.url

That reference to @_stack[@_index] resolves to undefined, which is then being passed into URL.resolve, which is then causing the error.

Any idea why this would happen?

Update

I've noticed that @_stack is empty, and @_index is -1. This shouldn't be possible, right?

Same issue when trying to simulate a $nodeElement->mouseOver() with Mink/Behat/Symfony2.1

TypeError: Parameter 'url' must be a string, not object
    at Url.parse (url.js:107:11)
    at urlParse (url.js:101:5)
    at Object.urlResolve [as resolve] (url.js:405:10)
    at Object.iframe.setAttribute (/usr/lib/node_modules/zombie/lib/zombie/jsdom_patches.js:164:43)
    at attrCopy (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:331:14)
    at Object.core.Node.cloneNode (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:636:18)
    at Object.core.Node.cloneNode (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:706:37)
    at Function.jQuery.extend.clone (/js/2225e47_jquery-1.8.2_2.js:6222:17)
    at Function.jQuery.extend.parseHTML (/js/2225e47_jquery-1.8.2_2.js:501:31)
    at jQuery.fn.jQuery.init (/js/2225e47_jquery-1.8.2_2.js:131:24)
    at jQuery (/js/2225e47_jquery-1.8.2_2.js:44:10)
    in /js/45a7194_jquery.jqModal_9.js

Node version is v0.10.15. Still digging for answers.

The zombie driver breaks with node version 0.8.24 (0.8.23 works ok). I believe this is due to the change:

2013.06.04, Version 0.8.24 (maintenance), c1a1ab067721ea17ef7b05ec5c68b01321017f05

* url: Properly parse certain oddly formed urls (isaacs)

A similar change (made on the same day) appears to have been made in 0.10.10 (although I've not studied the commits directly).

2013.06.04, Version 0.10.10 (Stable), 25e51c396aa23018603baae2b1d9390f5d9db496

* url: Properly parse certain oddly formed urls (isaacs)

I would recommend reverting to 0.8.23 or 0.10.9 in order to get this working. If you're not already using it I recommend nvm to manage your node installations.