laracasts / Behat-Laravel-Extension

Laravel extension for Behat functional testing.
MIT License
260 stars 73 forks source link

Configuration issues #69

Closed OAFCROB closed 7 years ago

OAFCROB commented 7 years ago

How do you config this package in Laravel 5.5 with the latest versions of Behat & Mink?

My behat.yml config is as follows after watching the Laracast video. I've updated the extensions to match what they appear to be in the relevant vendor folders.

#behat.yml
default:
    extensions:
        Laracasts\Behat\ServiceContainer\BehatExtension:
            env_path: .env.behat
        Behat\MinkExtension\ServiceContainer\MinkExtension:
            default_session: laravel
            base_url: http://localhost:8000
            laravel: ~

However, when I run behat it appears to crash out with no logging and just gives me the scenario. If I remove the APP_KEY from my config the behat tests appear to run but I get an error in my laravel logs.

Any suggestions would be appreciated @JeffreyWay.

Looking at the mink extension behat.yml would suggest that the config should be more like

default:
  suites:
    default:
      path: %paths.base%/features
      contexts: [Behat\MinkExtension\Context\MinkContext]
  extensions:
    Laracasts\Behat\ServiceContainer\BehatExtension:
        env_path: .env.behat
    Behat\MinkExtension:
      base_url: http://en.wikipedia.org/
      sessions:
        default:
          laravel: ~
alnutile commented 7 years ago

Can you paste in here your .env and .env.behat Just remove any real credentials and replace with fake values leaving the keys.

OAFCROB commented 7 years ago

As you can see it's pretty much the default .env still

# .env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=#ENCRYPTION_KEY
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://homestead-local.app

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=33060
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
# .env.behat
APP_ENV=acceptance
APP_KEY=#ENCRYPTION_KEY
OAFCROB commented 7 years ago

Done a little bit more digging and I'm now getting the following error [InvalidArgumentException] Session "laravel" is not registered. If I have time over the weekend I'll investigate it further

OAFCROB commented 7 years ago

Resolved for Laravel 5.5

# behat.yml
default:
    extensions:
        Laracasts\Behat:
            # env_path: .env.behat
        Behat\MinkExtension:
            default_session: laravel
            laravel: ~
alnutile commented 6 years ago

Should the readme be updated?

OAFCROB commented 6 years ago

No I don't think, so it's the Laracast video that is out of date. Maybe removing the laracast video or putting a warning message near it would help.