minkphp / phpunit-mink

Library for using Mink in PHPUnit tests. Supports session sharing between tests in a test case.
BSD 3-Clause "New" or "Revised" License
70 stars 20 forks source link

Mink Zombie driver isn't working #57

Open Shashikant86 opened 9 years ago

Shashikant86 commented 9 years ago

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 ?

aik099 commented 9 years ago

'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?
stof commented 9 years ago

@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)

Shashikant86 commented 9 years ago

@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.

aik099 commented 9 years ago

@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.

rbrisita commented 4 years ago

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.

aik099 commented 4 years ago

@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.