[英]Behat testing in laravel with javascript - not using test environment
I have a Laravel 5 project using Behat for acceptance testing. 我有一个使用Behat进行验收测试的Laravel 5项目。 I'm also running this in a Homestead Vagrant box.
我也在Homestead Vagrant盒子里运行它。
I have a page in my site that uses Javascript, and I'm using the Selenim2 driver with phantom js. 我的网站中有一个使用Javascript的页面,我正在使用带有幻像js的Selenim2驱动程序。 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: 这是我的
.env.behat
文件:
APP_ENV=acceptance
APP_DEBUG=true
DB_TYPE=sqlite
DB_PATH=acceptance.sqlite
And here is my behat.yml
file 这是我的
behat.yml
文件
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. 当我运行不使用javascript的场景时,它使用我的测试数据库(在
.env.behat
文件中指定)。
Thank you for any help! 感谢您的任何帮助!
To preserve Behat's testing environment when testing Javascript applications, you can use BehatLaravelJs package as a companion to Behat's Laravel extension. 为了在测试Javascript应用程序时保留Behat的测试环境,您可以使用BehatLaravelJs包作为Behat的Laravel扩展的伴侣。
Besides preserving the environment, it also addresses other limitations like authentication and database transactions when testing Javascript apps using a browser emulator. 除了保留环境之外,它还在使用浏览器模拟器测试Javascript应用程序时解决了身份验证和数据库事务等其他限制。
Environment variables set in the command line are not visible by your web server as it runs in a separate process. Web服务器在命令行中设置的环境变量在单独的进程中运行时不可见。
You could do either of the following: 您可以执行以下任一操作:
In both cases you'll need to update the base_url
in behat.yml
: 在这两种情况下,您都需要更新
behat.yml
的base_url
:
default:
extensions:
Behat\MinkExtension:
base_url: http://127.0.0.1/app_test.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.