phpunit-mink icon indicating copy to clipboard operation
phpunit-mink copied to clipboard

Mink Zombie driver isn't working

Open Shashikant86 opened this issue 10 years ago • 6 comments

Just trying to run my phpunit tests through Mink and Zombie driver. Here is my config

array(
            'driver' => 'zombie',

            // Defaults for this driver
            'port' => 8124,
            'driverOptions' => array(
                'node_bin' => 'node',
                'server_path' => null,
                'threshold' => 2000000,
                'node_modules_path' => '/Users/path to/node_modules/',
            ),
        ),

I have installed zombie locally with npm and exported NODE_PATH in my .zshrc

When I run my test I get following

PHPUnit 4.5.1 by Sebastian Bergmann and contributors.

E

Time: 4.12 seconds, Memory: 6.75Mb

There was 1 error:

1) BrandingHomeTest::testHomePage
RuntimeException: Server did not respond in time: () [Stopped]

/Users//vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php:399
/Users//vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php:300
/Users//vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/ZombieDriver.php:78
/Users/vendor/behat/mink/src/Session.php:70
/Users//vendor/aik099/phpunit-mink/library/aik099/PHPUnit/Session/IsolatedSessionStrategy.php:79
/Users/vendor/aik099/phpunit-mink/library/aik099/PHPUnit/BrowserTestCase.php:289
/Users/HomeTest.php:11
/Users/vendor/aik099/phpunit-mink/library/aik099/PHPUnit/BrowserTestCase.php:371
/Users/vendor/aik099/phpunit-mink/library/aik099/PHPUnit/BrowserTestCase.php:319

FAILURES!
Tests: 1, Assertions: 0, Errors: 1.

I am not sure if I am missing any config ?

Have someone tried that ?

Shashikant86 avatar Aug 21 '15 13:08 Shashikant86

'node_modules_path' => '/Users/path to/node_modules/',

You can override this from browser configuration array.

Questions/Ideas:

  1. If used Zombie version is 4.x or higher, then:
    • you need to specify path to IO.JS installation instead of Node.JS installation (I have no idea why "npm install" even gets Zombie 4.x)
    • downgrade to Zombie 3.x or smaller
  2. Does example from https://github.com/minkphp/MinkZombieDriver repo homepage work?

aik099 avatar Aug 21 '15 14:08 aik099

@aik099 npm only shows a warning when the engine does not match, but it does not prevent installing it (yeah, I also consider it as WTF)

stof avatar Aug 21 '15 14:08 stof

@aik099 Given up with this one 'MinkBundle' did good job with phpunit. It didn't count WebAssert assertions but writing another proxy did the job. Works great with GhostDriver + MinkBundle + PHUUnit combination.

Shashikant86 avatar Sep 13 '15 09:09 Shashikant86

@Shashikant86 , I don't understand you.

If you have a computer where Zombie + MinkBundle + PHPUnit-Mink are installed and Zombie works in MinkBundle, but doesn't in PHPUnit-Mink, then surely there is something wrong with set of options used to connect to Zombie.

I just wanted for you to print ones used at MinkBundle (at low level where ZombieServer class is created) and do the same for PHPUnit-Mink.

aik099 avatar Sep 13 '15 10:09 aik099

I am working on a legacy project, introduced functional testing and ran into this issue. There is a SessionProxy used that starts the session on the visit method call. A call like $this->getSession()->executeScript('alert("Hello");') will result on an error that the server didn't start. Either have a static session that stores the visit method result call to use in your tests or always call visit in each test.

rbrisita avatar Oct 29 '19 04:10 rbrisita

@rbrisita , That is an expected Mink behavior, where session is auto-started upon page is visited via Session->visit method call. You can't execute any JS on a page until you have actually opened it.

aik099 avatar Oct 29 '19 07:10 aik099