How to set custom command in yml file for the tests to run in CircleCI. Instead of cypress run, I want to set it to 'npm run tests'.
Below is my code-
- run: |
export CYPRESS_BASE_URL=https://localhost-${ENVIRONMENT}.abc.com
printenv
$(npm bin)/cypress run --record -b chrome
Related
I've just started using Component tests (Svelte) and they run in the Cypress GUI without problem. Now I want to put them in CI, but when I use run mode only the e2e tests are running.
What I've tried:
yarn cypress run
npx cypress run
You can pass the --component flag on the command line to run component tests:
yarn cypress run --component
On execution of command node_modules/.bin/cypress open it gives below error-
I have installed cypress using npm package only
npm -i init
npm install cypress --save-dev
When I checked the Cache folder - C:\Users\usename\AppData\Local\Cypress\Cache\10.6.0\Cypress
Cypress.exe file is present, but not open when command executed (node_modules/.bin/cypress open)
Cypress version installed is 10.6.0
Error-
It looks like you are running the Cypress binary directly.
This is not the recommended approach, and Cypress may not work correctly.
Please install the cypress NPM package and follow the instructions here:
https://on.cypress.io/installing-cypress
use: "npx cypress open" command
I am trying to integrate cypress to the bitbucket pipeline. And I am following the official documentation:
- step:
script:
# install dependencies
- npm ci
# run Cypress tests
- npm run e2e (env variables here)
I launch the container locally as follows:
docker run -v `pwd`:/mycode -it imagename /bin/sh
cd /mycode
and I run the steps in the script:
/mycode# npm ci; npm run e2e (env variables here)
But I get the following error:
/root/.cache/Cypress/8.2.0/Cypress/Cypress: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory
I ran apt-get install xvfb libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2, as per documentation when I got libgtk2.0-0 missing dependency and it threw the next one.
I also have added :nvm install "lts/*" --reinstall-packages-from="$(nvm current)" as a step to update node to the latest version and match cypress requirements,
but is there any general practice on how to integrate cypress in an existing project's pipeline and to work around these library issues?
Is the fix just to install the library or is there a better integration practice and something I'm missing?
You can actually use an official cypress image only for the step where you want to run the tests. You can choose the version which suits you the best.
- step:
name: run tests
image: cypress/browsers:node12.18.3-chrome87-ff82
script:
# install dependencies
- npm ci
# run Cypress tests
- npm run e2e (env variables here)
I am new on protractor platform and I tried to install and run the protractor locally on window, but I had no luck yet. Can anybody please tell me the exact step? I am able to install and run it globally.
For you
Create an empty folder as project base dir
Open a terminal and cd into the new folder
Execute npm init to generate package.json
Execute npm install -S protractor to install protractor locally and add it into project's dependencies. (you can check protractor will appear in package.json)
Prepare test script
Commit test script with package.json together
For others who want to run you code locally,
Clone your code to local
Open terminal and cd project base dir
Execute npm install to install dependencies to local
Execute protractor cli to execute test
I have the following configuration in .gitlab-ci.yml:
stages:
- build
build:
stage: build
script:
- npm install -g gulp
- npm install
- gulp
But the runner is only executing the first command (npm install -g gulp). It runs the first command and reports success, without executing the others.
The build log:
Running with gitlab-ci-multi-runner 1.6.1 (c52ad4f)
Using Shell executor...
Running on WINBUILDER...
Fetching changes...
HEAD is now at 2df18c5 Update .gitlab-ci.yml
From https://.../client
2df18c5..b4efae8 master -> origin/master
Checking out b4efae85 as master...
$ npm install -g gulp
C:\Users\Administrator\AppData\Roaming\npm\gulp -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js
C:\Users\Administrator\AppData\Roaming\npm
`-- gulp#3.9.1
Build succeeded
I've seen several config examples using multiple commands in a stage. I don't understand why the other commands are not running.
It's actually an NPM bug as described here:
https://github.com/npm/npm/issues/2938
NPM closes the shell upon exit and subsequent commands are not called.
A workaround is described in the issue above. Just add a call command before calling NPM:
stages:
- build
build:
stage: build
script:
- call npm install -g gulp
- call npm install
- gulp