Reputation: 1162
I have a Laravel 5 project using Behat for acceptance testing. I'm also running this in a Homestead Vagrant box.
I have a page in my site that uses Javascript, and I'm using the Selenim2 driver with phantom js. Selenium seems to be working fine. The problem is when I run my test it uses the development database instead of the testing one. Here's my .env.behat
file:
APP_ENV=acceptance
APP_DEBUG=true
DB_TYPE=sqlite
DB_PATH=acceptance.sqlite
And here is my behat.yml
file
default:
extensions:
Laracasts\Behat: ~
# env_path: .env.behat
Behat\MinkExtension:
default_session: laravel
laravel: ~
javascript_session: selenium2
base_url: http://127.0.0.1/
selenium2:
wd_host: "http://localhost:8643/wd/hub"
selenium2: ~
When I run scenario that doesn't use javascript it uses my test database (as specified in the .env.behat
file.
Thank you for any help!
Upvotes: 4
Views: 783
Reputation: 18455
To preserve Behat's testing environment when testing Javascript applications, you can use BehatLaravelJs package as a companion to Behat's Laravel extension.
Besides preserving the environment, it also addresses other limitations like authentication and database transactions when testing Javascript apps using a browser emulator.
Upvotes: 1
Reputation: 36201
Environment variables set in the command line are not visible by your web server as it runs in a separate process.
You could do either of the following:
In both cases you'll need to update the base_url
in behat.yml
:
default:
extensions:
Behat\MinkExtension:
base_url: http://127.0.0.1/app_test.php
Upvotes: 1