MinkExtension icon indicating copy to clipboard operation
MinkExtension copied to clipboard

Zombie is throwing syntax error

Open iamstoick opened this issue 10 years ago • 20 comments

Behat newbie here. Started Behat 2 days ago and I am working on using Zombie which I am having trouble to make it work.

gerald@von-viel:~/Repo/drupalproject/tests$ bin/behat --stop-on-failure features/home.feature 
Feature: Homepage
  In order to know the website is running
  As a website user
  I need to be able to view the site title and login

  [RuntimeException]                                                                                                                                    
  Exception has been thrown in "beforeScenario" hook, defined in FeatureContext::beforeScenario()                                                       

  Server process has been terminated: (1) [/home/gerald/Repo/drupalproject/tests/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:418  
    set nodeName() { throw new core.DOMException();},                                                                                                   
                 ^                                                                                                                                      
  SyntaxError: Unexpected token )                                                                                                                       
      at exports.runInThisContext (vm.js:73:16)                                                                                                         
      at Module._compile (module.js:443:25)                                                                                                             
      at Object.Module._extensions..js (module.js:478:10)                                                                                               
      at Module.load (module.js:355:32)                                                                                                                 
      at Function.Module._load (module.js:310:12)                                                                                                       
      at Module.require (module.js:365:17)                                                                                                              
      at require (module.js:384:17)                                                                                                                     
      at Object.<anonymous> (/home/gerald/Repo/drupalproject/tests/node_modules/zombie/node_modules/jsdom/lib/jsdom/level2/core.js:1:94)              
      at Module._compile (module.js:460:26)                                                                                                             
      at Object.Module._extensions..js (module.js:478:10)                                                                                               
  ]                                                                                                                                                     

behat [--init] [-f|--format="..."] [--out="..."] [--lang="..."] [--[no-]ansi] [--[no-]time] [--[no-]paths] [--[no-]snippets] [--[no-]snippets-paths] [--[no-]multiline] [--[no-]expand] [--story-syntax] [-d|--definitions="..."] [--name="..."] [--tags="..."] [--cache="..."] [--strict] [--dry-run] [--stop-on-failure] [--rerun="..."] [--append-snippets] [--append-to="..."] [features]

Here is my feature:

Feature: Homepage
  In order to know the website is running
  As a website user
  I need to be able to view the site title and login

  Scenario: Viewing the site title
    Given I am on the homepage
    Then I should see "Welcome"

  @api @mink:zombie
  Scenario: See "Add Content"
    Given I am logged in as a user with the "administrator" role
      And I am on the homepage
    Then I should see "Add content"
    When I click "Add content"
    # And I wait for "9" seconds
    Then I should see "Use basic pages for your static content"

Some details about my environment:

gerald@von-viel:~/Repo/drupalproject/tests$ npm list zombie
/home/gerald/Repo/drupalproject/tests
└── [email protected] 
Behat 2.5.0
mink-zombie-driver (v1.1.0)

behat.yml

default:
  paths:
    features: 'features'
  extensions:
    Behat\MinkExtension\Extension:
      goutte: ~
      selenium2: ~
      zombie: ~
      base_url: http://local.drupalproject.com
      default_session: 'zombie'
      javascript_session: zombie
      zombie:
        node_modules_path: /home/gerald/Repo/drupalproject/tests/node_modules/
    Drupal\DrupalExtension\Extension:
      blackbox: ~
      api_driver: drupal
      drush:
        alias: drupal.local
      drupal:
        drupal_root: '../www'
      subcontexts:
        paths:
          - '../www/sites/all/modules'
      selectors:
        error_message_selector: .messages.error
        success_message_selector: .messages.status
      text:
        username_field: Email

iamstoick avatar Oct 18 '15 15:10 iamstoick

What is your Zombie and NodeJS version? I'm suspecting that you're using Zombie 4.x version on NodeJS, which won't work.

You either need to install Zombie 3.x specifically via npm or configure MinkZombieDriver to use IoJS installation (harder).

aik099 avatar Oct 18 '15 16:10 aik099

Hmnn, I am using Zombie 1.4.1, would that be a problem?

gerald@von-viel:~/Repo/drupalproject/tests$ node --version
v0.12.7

gerald@von-viel:~/Repo/drupalproject/tests$ npm list zombie
/home/gerald/Repo/drupalproject/tests
└── [email protected] 

Thank you for your help. Appreciate it.

iamstoick avatar Oct 18 '15 22:10 iamstoick

There were 2 major releases since that version for both Zombie and MinkZombieDriver. I recommend you upgrading at least to Zombie 2.

aik099 avatar Oct 19 '15 07:10 aik099

We don't support Zombie 1.4. We support Zombie 2, 3 and 4 in the driver

stof avatar Oct 19 '15 09:10 stof

But theoretically it should be working, because @geraldvillorente is using MinkZombieDriver and Zombie versions that were working together several years ago :wink:

aik099 avatar Oct 19 '15 09:10 aik099

@aik099 no. this version of the Zombie driver was not working properly (which is why we rewrote it almost entirely for Zombie 2)

stof avatar Oct 19 '15 09:10 stof

This was long time ago. I already forgot about these dark times. Maybe we can mention supported Zombie versions or better yet not supported ones on driver repo homepage?

aik099 avatar Oct 19 '15 10:10 aik099

We already document it: https://github.com/minkphp/MinkZombieDriver#installation--compatibility

and 1.1.0 of the driver is very old

stof avatar Oct 19 '15 10:10 stof

Good to know. The problem is, that people report driver specific issues to Mink and MinkExtension repos instead of corresponding driver repos even though contribution docs clearly say where issues should be reported.

aik099 avatar Oct 19 '15 11:10 aik099

@stof and @aik099 I updated Zombie to 4.1.0 and re ran my test but I got a new error. Please see below.

gerald@von-viel:~/Repo/newplayexchange/tests$ bin/behat --stop-on-failure features/home.feature 
Feature: Homepage
  In order to know the website is running
  As a website user
  I need to be able to view the site title and login

  [RuntimeException]                                                                                                                                           
  Exception has been thrown in "beforeScenario" hook, defined in FeatureContext::beforeScenario()                                                              

  Server process has been terminated: (1) [/home/gerald/Repo/drupalproject/tests/node_modules/zombie/node_modules/jsdom/lib/jsdom/living/node-iterator.js:3  
  const defineGetter = require("../utils").defineGetter;                                                                                                       
  ^^^^^                                                                                                                                                        
  SyntaxError: Use of const in strict mode.                                                                                                                    
      at exports.runInThisContext (vm.js:73:16)                                                                                                                
      at Module._compile (module.js:443:25)                                                                                                                    
      at Object.Module._extensions..js (module.js:478:10)                                                                                                      
      at Module.load (module.js:355:32)                                                                                                                        
      at Function.Module._load (module.js:310:12)                                                                                                              
      at Module.require (module.js:365:17)                                                                                                                     
      at require (module.js:384:17)                                                                                                                            
      at Object.<anonymous> (/home/gerald/Repo/drupalproject/tests/node_modules/zombie/node_modules/jsdom/lib/jsdom/living/index.js:22:1)                    
      at Module._compile (module.js:460:26)                                                                                                                    
      at Object.Module._extensions..js (module.js:478:10)                                                                                                      
      at Module.load (module.js:355:32)                                                                                                                        
      at Function.Module._load (module.js:310:12)                                                                                                              
      at Module.require (module.js:365:17)                                                                                                                     
      at require (module.js:384:17)                                                                                                                            
      at Object.<anonymous> (/home/gerald/Repo/drupalproject/tests/node_modules/zombie/lib/dom/index.js:5:11)                                                
      at Module._compile (module.js:460:26)                                                                                                                    
  ]                                                                                                                                                            


behat [--init] [-f|--format="..."] [--out="..."] [--lang="..."] [--[no-]ansi] [--[no-]time] [--[no-]paths] [--[no-]snippets] [--[no-]snippets-paths] [--[no-]multiline] [--[no-]expand] [--story-syntax] [-d|--definitions="..."] [--name="..."] [--tags="..."] [--cache="..."] [--strict] [--dry-run] [--stop-on-failure] [--rerun="..."] [--append-snippets] [--append-to="..."] [features]

iamstoick avatar Oct 19 '15 12:10 iamstoick

@geraldvillorente AFAIK, Zombie 4 requires node 3+

stof avatar Oct 19 '15 12:10 stof

@aik099 Apology if this a not the correct channel to report this problem.

iamstoick avatar Oct 19 '15 12:10 iamstoick

That's what I've already mentioned above. Please use Zombie 3.x

aik099 avatar Oct 19 '15 12:10 aik099

Will install Zombie 3 and report the result asap. Thanks guys.

iamstoick avatar Oct 19 '15 12:10 iamstoick

Just followed your advice and I am running Zombie 3.1.1 and here is the new error. Thank you for your patience.

gerald@von-viel:~/Repo/drupalproject/tests$ bin/behat --stop-on-failure features/home.feature 
Feature: Homepage
  In order to know the website is running
  As a website user
  I need to be able to view the site title and login

  [RuntimeException]                                                                               
  Exception has been thrown in "beforeScenario" hook, defined in FeatureContext::beforeScenario()  

  Server process has been terminated: (1) [/tmp/mink_nodejs_serverAD1Jqn:24                        
    throw new Error("Your zombie.js version is not compatible with this driver.                    
          ^                                                                                        
  Error: Your zombie.js version is not compatible with this driver. Please use a version <= 1.4.1  
      at Object.<anonymous> (/tmp/mink_nodejs_serverAD1Jqn:24:9)                                   
      at Module._compile (module.js:460:26)                                                        
      at Object.Module._extensions..js (module.js:478:10)                                          
      at Module.load (module.js:355:32)                                                            
      at Function.Module._load (module.js:310:12)                                                  
      at Function.Module.runMain (module.js:501:10)                                                
      at startup (node.js:129:16)                                                                  
      at node.js:814:3                                                                             
  ]                                                                                                

behat [--init] [-f|--format="..."] [--out="..."] [--lang="..."] [--[no-]ansi] [--[no-]time] [--[no-]paths] [--[no-]snippets] [--[no-]snippets-paths] [--[no-]multiline] [--[no-]expand] [--story-syntax] [-d|--definitions="..."] [--name="..."] [--tags="..."] [--cache="..."] [--strict] [--dry-run] [--stop-on-failure] [--rerun="..."] [--append-snippets] [--append-to="..."] [features]

iamstoick avatar Oct 19 '15 13:10 iamstoick

@geraldvillorente use the maintained version of the driver too, not the several years old 1.1.0 version.

stof avatar Oct 19 '15 13:10 stof

@stof Thank you. I setup a plain vanilla environment and everything is working fine.

gerald@von-viel:~/Web/drupal7$ bin/behat --stop-on-failure features/home.feature 
Feature: Homepage
  In order to know the website is running
  As a website user
  I need to be able to view the site title and login

  @api @mink:zombie
  Scenario: See "Add Content"                                    # features/home.feature:7
    Given I am logged in as a user with the "administrator" role # Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRole()
    And I am on the homepage                                     # Drupal\DrupalExtension\Context\MinkContext::iAmOnHomepage()
    Then I should see "Add content"                              # Drupal\DrupalExtension\Context\MinkContext::assertPageContainsText()
    When I click "Add content"                                   # Drupal\DrupalExtension\Context\MinkContext::assertClick()
    Then I should see "Use basic pages for your static content"  # Drupal\DrupalExtension\Context\MinkContext::assertPageContainsText()

1 scenario (1 passed)
5 steps (5 passed)
0m36.60s (16.83Mb)

The error is only happening on an existing project which is using Behat 2 and Selenium. So what I am doing right now is replacing Selenium with Zombie and this is where the pain came in. Due to versions incompatibility and my lack of knowledge (newbie) in this technology I am now playing in the dark trying to figure out how to make this Zombie works. Thank you for your patience.

iamstoick avatar Oct 19 '15 13:10 iamstoick

@geraldvillorente latest Mink versions are compatible with Behat 2 too. But you were using a very old version of Mink

stof avatar Oct 19 '15 14:10 stof

@aik099 Is this problem still exists .. I am facing this "Error while processing event 'click': "SyntaxError: Unexpected token u\n at Object.parse (native)\n " /home/ubuntu └── [email protected] :~$ node --version v5.2.0 :~$ sudo npm -v 3.10.5 node_modules_path: '/home/ubuntu/node_modules' mink-zombie-driver v1.4.0 I am also Behat Newbie and using default features. The error shows at "When I press "login_button"" .. Do I need to downgrade the zombie?

rim16 avatar Aug 05 '16 17:08 rim16

What if you clone https://github.com/minkphp/MinkZombieDriver repo and run tests in it?

If tests will pass, then probably combination of page HTML and executed commands in the driver uncover some edge case not covered in test suite. In that case please provide:

  1. HTML of the page under test
  2. debug output (behat -v) from running Behat where executed Mink commands are shown

aik099 avatar Aug 05 '16 19:08 aik099