https://cypress.io logo
Quick question regarding Gitlab CI setup
# i-need-help
e
In the "Basic Setup" section (https://docs.cypress.io/guides/continuous-integration/gitlab-ci#Basic-Setup) it references the NPM script
start:ci
- there is no mention of what commands are in this script elsewhere in the documentation that I could find - if someone knows that would be great.
m
Hi @elegant-insurance-66438 It seems that there is an error in this example as there is no script with this name in https://github.com/cypress-io/cypress-example-kitchensink/blob/master/package.json!
e
Yep, I did check there as well. This is what I'm currently using: - npm install -g serve - npm install -g wait-on - serve -s build & - wait-on http://localhost:3000 but I'm having a tough time getting things working so wanted to use the exact commands (ie. whatever start:ci refers to) in the documentation so I could rule things out.
m
You should be able to use
npm start
instead of
npm run start:ci
In CI workflows we normally use `npm ci`not
npm install
Before you try to get this working in GitLab I would recommend running it locally using the commands in the README file, so you can get familiar with it.
e
Yep, I'm using
npm ci
in the command above, and realize the reason for doing so. I'm hesitant to just use
npm start
as I would like to test the actual build - I will try it though, thanks.
m
You're welcome. Thanks for raising the issue about the script. I will ask for the documentation to be corrected. There is a live workflow example for GitHub, but unfortunately there is not one for GitLab.
e
ok, thanks
m
npm start
is the correct command and it is referred to in the explanation text. It is just the code examples which are incorrect. The kitchensink example has its own server included. You do not need to use
serve
. It also has `start-server-and-test`included, which means you don't need
wait-on
. The `build`command in this repository does not really build the app, it is just a lint command.
See https://github.com/cypress-io/cypress-documentation/pull/5234 for documentation correction. Also, if you try to use the `firefox`example with a Docker container, that probably won't work either (due to https://github.com/cypress-io/cypress-docker-images/issues/871). If you hit that issue, then probably
chrome
would work.
e
npm start
ultimately calls
serve
- please see https://github.com/cypress-io/cypress-example-kitchensink/blob/master/scripts/start.js - I am just calling it directly in my
.gitlab-ci.yml
instead and need it to serve the build that I want to run the tests against. The latest issue I have is 503 errors from http://localhost:3000 . Getting this up and running has cost me a couple of days so will be getting input from our devops.
m
Yes, you are right that the script calls
serve
. Sorry for my misleading comment. Good luck with getting it working in your environment!
e
No worries. Thanks - I'll provide any updates once it is up and running for reference.
The issue with 503 errors was resolved by replacing the occurrences of http://localhost:3000/ to http://127.0.0.1/ in the
cypress.config.ts
and in the
.gitlab-ci.yml
- all working now 🙂