Jibé Barth

🇫🇷 Web developer

[Sylius] Get ready to add a behat feature that use javascript

Published Dec 9, 2023

While contributing on Sylius, I had to add a test for a fix.

There was already some behat test regarding the feature, but I had trouble to get ready to launch them in my own environment, and Makefile provided by Sylius didn't help me.

Here is how I proceed.

1. Launching Sylius in test mode

First, you need to be able to launch the sylius, but in Test mode.

In the docker-compose.yml provided, I commented everything except the mysql container. In my case, I have all php tools installed on my host, no need for others containers.

Once started, change the .env to use it (ie adding password 😅)


And enable the test mode


Then, initialize correctly the database.

php bin/console doctrine:database:create
php bin/console doctrine:migration:migrate
php bin/console sylius:fixture:load -n

And finally, start the webserver thanks to Symfony binary.

symfony local:server:start -d

You can specify the port to start :

symfony local:server:start -d --port=8080

[!IMPORTANT] If the port is not on 8080, you'll have to modify the behat.yml.dist file

2. Running a chrome in headless mode

I found this on the dmore/chrome-mink-driver readme.

Open a new terminal and start a new chrome headless :

google-chrome --disable-gpu --headless --remote-debugging-address= --remote-debugging-port=9222

Adjust binary to google-chrome-stable or google-chrome-unstable if needed.

3. Launch behat

Finally, you can launch behat


You can target directly the feature file you are editing, to avoid launching the huge test suite.

vendor/bin/behat features/checkout/addressing_order/sign_in_during_addressing_step.feature  -n

If a test failed, you can find a screenshot and the html page in etc/build directory.

If you have any Timeout like this,


It's probably the port is not the same in the behat.yml.dist and the server you started.

You can change the port in the behat.yml.dist :

    # ...
            files_path: "%paths.base%/src/Sylius/Behat/Resources/fixtures/"
            base_url: "" # <-- HERE