Gitlab CI pipeline for Cypress test fails

I have tried several different ways but still can’t get the Cypress test to run successfully on Gitlab CI. Below is my basic setup/config. I’m not sure what is wrong with my setup.

.gitlab-ci.yaml

stages:
  - test
test:
  image: cypress/browsers:node-20.9.0-chrome-118.0.5993.88-1-ff-118.0.2-edge-118.0.2088.46-1
  stage: test
  script:
    # install dependencies
    - npm ci
    # start the server in the background
    - npm start &
    # run Cypress tests
    - npx cypress run --browser chrome
  tags:
    - shared

package.json

{
  "name": "MyApp Automation",
  "version": "1.0.0",
  "description": "Cypress Automation Framework for MyApp",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "John Doe",
  "license": "ISC",
  "devDependencies": {
    "cypress": "^13.9.0",
    "typescript": "^5.4.5"
  },
  "dependencies": {
    "cypress-real-events": "^1.12.0"
  }
}

cypress.config.js

const { defineConfig } = require("cypress");

module.exports = defineConfig({
  viewportHeight: 1080,
  viewportWidth: 1920,
  video: false,
  e2e: {
    baseUrl: 'https://mySiteURL.io/',
    specPattern: 'cypress/e2e/loginTest.js',
    excludeSpecPattern: ['cypress/e2e/1-getting-started', 'cypress/e2e/2-advanced-examples'],
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
  },
});

Job logs

Running with gitlab-runner 16.11.0 (91a27b2a)
  on Platform EKS Runner FY7CgVe2y, system ID: r_xbSm4hFEHvfo
Resolving secrets
Preparing the "kubernetes" executor
00:00
Using Kubernetes namespace: [MASKED]
Using Kubernetes executor with image cypress/browsers:node-20.9.0-chrome-118.0.5993.88-1-ff-118.0.2-edge-118.0.2088.46-1 ...
Using attach strategy to execute scripts...
Preparing environment
03:38
Using FF_USE_POD_ACTIVE_DEADLINE_SECONDS, the Pod activeDeadlineSeconds will be set to the job timeout: 1h0m0s...
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotInitialized: "containers with incomplete status: [init-permissions]"
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotInitialized: "containers with incomplete status: [init-permissions]"
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod [MASKED]/runner-fy7cgve2y-project-207-concurrent-0-utr7mtms to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Running on runner-fy7cgve2y-project-207-concurrent-0-utr7mtms via gitlab-runner-premium-7575fb5f75-d6l48...
Getting source from Git repository
00:12
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/platform/studio/automation/.git/
Created fresh repository.
Checking out 69d78dd6 as detached HEAD (ref is main)...
Skipping Git submodules setup
Executing "step_script" stage of the job script
08:35
$ npm ci
(node:35) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:35) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:35) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:35) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:35) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:35) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:35) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:35) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:35) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
added 177 packages, and audited 178 packages in 8m
39 packages are looking for funding
  run `npm fund` for details
found 0 vulnerabilities
$ npm start &
$ npx cypress run --browser chrome
npm ERR! Missing script: "start"
npm ERR! 
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR! 
npm ERR! To see a list of scripts, run:
npm ERR!   npm run
npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-06-20T15_30_36_651Z-debug-0.log
[STARTED] Task without title.
[FAILED] Cypress verification timed out.
[FAILED] 
[FAILED] This command failed with the following output:
[FAILED] 
[FAILED] /root/.cache/Cypress/13.9.0/Cypress/Cypress --no-sandbox --smoke-test --ping=140
[FAILED] 
[FAILED] ----------
[FAILED] 
[FAILED] [137:0620/153045.252814:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[FAILED] 
[FAILED] ----------
[FAILED] 
[FAILED] Platform: linux-x64 (Debian - 11.8)
[FAILED] Cypress Version: 13.9.0
Cypress verification timed out.
This command failed with the following output:
/root/.cache/Cypress/13.9.0/Cypress/Cypress --no-sandbox --smoke-test --ping=140
----------
[137:0620/153045.252814:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
----------
Platform: linux-x64 (Debian - 11.8)
Cypress Version: 13.9.0
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: command terminated with exit code 1

Your missing a start script inside your package.json