Zombie is throwing syntax error
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
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).
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.
There were 2 major releases since that version for both Zombie and MinkZombieDriver. I recommend you upgrading at least to Zombie 2.
We don't support Zombie 1.4. We support Zombie 2, 3 and 4 in the driver
But theoretically it should be working, because @geraldvillorente is using MinkZombieDriver and Zombie versions that were working together several years ago :wink:
@aik099 no. this version of the Zombie driver was not working properly (which is why we rewrote it almost entirely for Zombie 2)
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?
We already document it: https://github.com/minkphp/MinkZombieDriver#installation--compatibility
and 1.1.0 of the driver is very old
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.
@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]
@geraldvillorente AFAIK, Zombie 4 requires node 3+
@aik099 Apology if this a not the correct channel to report this problem.
That's what I've already mentioned above. Please use Zombie 3.x
Will install Zombie 3 and report the result asap. Thanks guys.
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]
@geraldvillorente use the maintained version of the driver too, not the several years old 1.1.0 version.
@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.
@geraldvillorente latest Mink versions are compatible with Behat 2 too. But you were using a very old version of Mink
@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?
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:
- HTML of the page under test
- debug output (
behat -v) from running Behat where executed Mink commands are shown