简体   繁体   中英

Travis CI: start cypress on rails server

I have created a public-repo for testing the private-repo .

I have the same config on my private-repo and public-repo :

{
      "os": "linux",
      "env": "BUNDLE_GEMS__CONTRIBSYS__COM=1234567890",
      "dist": "trusty",
      "cache": {
        "bundler": true,
        yarn: true,
        "directories": [
          "~/.cache"
        ]
      },
      "group": "stable",
      "addons": {
        "postgresql": "9.4"
      },
      "script": [
        "$(yarn bin)/cypress run"
      ],
      "install": [
        "yarn add cypress"
      ],
      "node_js": 10,
      "language": "node_js",
      "services": [
        "redis-server",
        "postgresql"
      ],
      "before_script": [
        "rails server -p 3000 -b 127.0.0.1 &",
        "psql -c 'create database travis_ci_test;' -U postgres",
        "RAILS_ENV=test bundle exec rake db:schema:load",
        "RAILS_ENV=test bundle exec rake db:seed"
      ],
      "before_install": [
        "gem install bundler",
        "bundle install"
      ]
    }

But I don't understand why I have this error message in my private-repo:

Testing
        1) can i access to 127.0.0.1
        2) can i access to localhost
      0 passing (1m)
      2 failing
      1) Testing can i access to 127.0.0.1:
         CypressError: cy.request() timed out waiting 30000ms for a response from your server.
    The request we sent was:
    Method: GET
    URL: http://127.0.0.1:3000/
    No response was received within the timeout.
          at Object.cypressErr (http://localhost:36431/__cypress/runner/cypress_runner.js:68076:11)
          at Object.throwErr (http://localhost:36431/__cypress/runner/cypress_runner.js:68041:18)
          at Object.throwErrByPath (http://localhost:36431/__cypress/runner/cypress_runner.js:68068:17)
          at http://localhost:36431/__cypress/runner/cypress_runner.js:59657:25
          at tryCatcher (http://localhost:36431/__cypress/runner/cypress_runner.js:7091:23)
          at http://localhost:36431/__cypress/runner/cypress_runner.js:2408:41
          at tryCatcher (http://localhost:36431/__cypress/runner/cypress_runner.js:7091:23)
          at Promise._settlePromiseFromHandler (http://localhost:36431/__cypress/runner/cypress_runner.js:5113:31)
          at Promise._settlePromise (http://localhost:36431/__cypress/runner/cypress_runner.js:5170:18)
          at Promise._settlePromise0 (http://localhost:36431/__cypress/runner/cypress_runner.js:5215:10)
          at Promise._settlePromises (http://localhost:36431/__cypress/runner/cypress_runner.js:5290:18)
          at Async._drainQueue (http://localhost:36431/__cypress/runner/cypress_runner.js:2023:16)
          at Async._drainQueues (http://localhost:36431/__cypress/runner/cypress_runner.js:2033:10)
          at Async.drainQueues (http://localhost:36431/__cypress/runner/cypress_runner.js:1907:14)
          at

My public repo : https://github.com/joffreyBerrier/rails-travis

My public travis build : https://travis-ci.org/joffreyBerrier/rails-travis/builds

My Cypress test :

describe('Testing', () => {
      it('can i access to 127.0.0.1', () => {
        cy.request('http://127.0.0.1:3000');
      });

      it('can i access to localhost', () => {
        cy.request('localhost:3000');
      });
    });

OP solved his issue using the following .travis.yml :

language: node_js
node_js:
  - 9.11.2
addons:
  postgresql: "9.4"
services:
  - redis-server
  - postgresql
cache:
  bundler: true
  yarn: true
  directories:
    - /home/travis/.rvm/
    - ~/.cache
before_install:
  - gem install bundler
  - bundle install
install:
  - yarn add cypress
before_script:
  - psql -c 'create database travis_ci_test;' -U postgres
  - bin/rails server &
  - bundle exec rake assets:precompile
  - sleep 10
  - RAILS_ENV=test bundle exec rake db:schema:load
  - RAILS_ENV=test bundle exec rake your_seed
script:
  - $(yarn bin)/cypress run --record
  - bundle exec rspec spec/controllers spec/models spec/jobs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM