Question

I have tests that pass fine on my local machine, but I am trying to use Travis-CI and the tests do not work. I have ajax calls and I have the following in my FeatureContext.php to wait for them to complete:

/**
 * Wait either $duration milliseconds or until jQuery: is undefined or has no active ajax calls AND has no active animations
 *
 * @param int $duration
 */
protected function jqueryWait($duration = 1000)
{
    $this->getSession()->wait($duration, '(typeof jQuery === \'undefined\' || (0 === jQuery.active && 0 === jQuery(\':animated\').length))');
}

/**
 * @When /^I wait for the response$/
 */
public function iWaitForTheResponse()
{
    $this->jqueryWait(20000);
}

It doesn't wait during the Travis-CI test. Here are my behat.yml and .travis.yml files:

behat.yml

default:
    paths:
        features: features
        bootstrap: features/bootstrap
    context:
#        class: FeatureContext
        class: BConway\TrackerBundle\Features\Context\FeatureContext
    formatter:
        name: pretty,html
        parameters:
            decorated:              true
            verbose:                true
            time:                   true
            language:               en
            output_path:            null,test_report.html
            multiline_arguments:    true
    extensions:
        Behat\Symfony2Extension\Extension:
            mink_driver: true
            kernel:
                env: test
                debug: true
        Behat\MinkExtension\Extension:
            base_url: 'http://kimweighttracker.dev/app_test.php/'
            default_session: goutte
            zombie: ~
            goutte: ~
            selenium2:
                capabilities: { "browser": "firefox" }

annotations:
    paths:
        features: features/annotations

closures:
    paths:
        features: features/closures

user:
    filters:
        tags:   "@user"

goal:
    filters:
        tags:   "@goal"

entry:
    filters:
        tags:   "@entry"

behavior:
    filters:
        tags:   "@behavior"

.travis.yml

language: php

php:
  - 5.4

before_script:
    # Install php packages
    - sudo apt-get update > /dev/null
    - sudo apt-get install -y --force-yes apache2 libapache2-mod-php5 php5-curl php5-mysql php5-intl

    # Create VirtualHost
    - sudo sed -i -e "s,/var/www,$(pwd)/web,g" /etc/apache2/sites-available/default
    - sudo sed -i -e "/DocumentRoot/i\ServerName kimweighttracker.dev" /etc/apache2/sites-available/default
    - echo "127.0.0.1 kimweighttracker.dev" | sudo tee -a /etc/hosts
    - sudo /etc/init.d/apache2 restart

    # Copy skeleton parameters file
    - cp app/config/parameters.yml.dist app/config/parameters.yml

    # Update composer
    - composer self-update
    - composer install --dev --prefer-dist

    - app/console -n doctrine:database:create -e=test > /dev/null
    - app/console -n doctrine:migrations:migrate -e=test > /dev/null
    - chmod -R 777 app/cache app/logs
    - app/console --env=test cache:warmup
    - chmod -R 777 app/cache app/logs

    # Setup selenium
    - "sh -e /etc/init.d/xvfb start"
    - "export DISPLAY=:99.0"
    - "wget http://selenium.googlecode.com/files/selenium-server-standalone-2.31.0.jar"
    - "java -jar selenium-server-standalone-2.31.0.jar > /dev/null &"
    - sleep 5


script: bin/behat
Was it helpful?

Solution

I figured it out. I forgot to dump my assets in the travis config. I simply added:

- app/console assetic:dump

and everything works great.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top