Search code examples
vue.jscypressgitlab-ci-runner

Cypress E2E Testing VueJS with GitLab Runner returns 404 not found


I have the following simple GitLab CI file

stages:
  - e2e_test

e2e_test:
  stage: e2e_test
  tags:
    - test
  script:
    - npm config set strict-ssl false
    - npm install
    - npm run test:e2e:ci

I am running the above script in a shell runner for very specific corporate reasons.

This script results in a 404 error with the following log

 npm run test:e2e:ci
> todo-app@0.1.0 test:e2e:ci /home/gitlab-runner/builds/UHz6XzwM/0/microservices-and-cognitive-solutions/demos/microservice-concept/todo-app
> vue-cli-service test:e2e --headless
 INFO  Starting e2e tests...
 INFO  Starting development server...
 DONE  Compiled successfully in 8865ms6:51:36 PM
  App running at:
  - Local:   http://localhost:8083/ 
  - Network: http://10.108.201.150:8083/
  App is served in production mode.
  Note this is for preview or E2E testing only.
====================================================================================================
  (Run Starting)
tput: No value for $TERM and no -T specified
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    3.8.3                                                                              │
  │ Browser:    Electron 78 (headless)                                                             │
  │ Specs:      1 found (test.js)                                                                  │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                    
  Running:  test.js                                                                         (1 of 1)
Browserslist: caniuse-lite is outdated. Please run the following command: `npm update`
  My First Test
    1) Visits the app root url
  0 passing (341ms)
  1 failing
  1) My First Test Visits the app root url:
     CypressError: cy.visit() failed trying to load:
http://localhost:8083/
The response we received from your web server was:
  > 404: Not Found
This was considered a failure because the status code was not '2xx'.
If you do not want status codes to cause failures pass the option: 'failOnStatusCode: false'
      at Object.cypressErr (http://localhost:8083/__cypress/runner/cypress_runner.js:86207:11)
      at Object.throwErr (http://localhost:8083/__cypress/runner/cypress_runner.js:86162:18)
      at Object.throwErrByPath (http://localhost:8083/__cypress/runner/cypress_runner.js:86194:17)
      at http://localhost:8083/__cypress/runner/cypress_runner.js:71493:31
      at visitFailedByErr (http://localhost:8083/__cypress/runner/cypress_runner.js:71006:12)
      at http://localhost:8083/__cypress/runner/cypress_runner.js:71474:22
      at tryCatcher (http://localhost:8083/__cypress/runner/cypress_runner.js:120203:23)
      at Promise._settlePromiseFromHandler (http://localhost:8083/__cypress/runner/cypress_runner.js:118139:31)
      at Promise._settlePromise (http://localhost:8083/__cypress/runner/cypress_runner.js:118196:18)
      at Promise._settlePromise0 (http://localhost:8083/__cypress/runner/cypress_runner.js:118241:10)
      at Promise._settlePromises (http://localhost:8083/__cypress/runner/cypress_runner.js:118316:18)
      at Async../node_modules/bluebird/js/release/async.js.Async._drainQueue (http://localhost:8083/__cypress/runner/cypress_runner.js:114928:16)
      at Async../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:8083/__cypress/runner/cypress_runner.js:114938:10)
      at Async.drainQueues (http://localhost:8083/__cypress/runner/cypress_runner.js:114812:14)

If I clone the same repository on the same server and manually run the following commands in the terminal it works fine.

npm install
npm run test:e2e:ci

Any idea why the same commands would fail in a GitLab runner shell but working in a user shell


Solution

  • I found the problem to fix my issue. I needed to set a no_proxy environment entry in my gitlab-runner config.toml file. This won't affect everyone, but since i am behind a corporate proxy, I needed it.

    export no_proxy="localhost"