I am using cypress testing server.
When I am running my tests with cypress window, its working right.
$./node_modules/.bin/cypress open --project tests/e2e/
But when I am trying to run it with command line, my tests didn't worked.
In screenshots I see, that my link doesn't loading and my page is empty and my tests result is false.
I am running with selected command
$ ./node_modules/.bin/cypress run --config pageLoadTimeout=10000,watchForFileChanges=false --project tests/e2e/
How I can run my tests with command line
First you should navigate to your project folder, for example if your cypress test is lying in below folder
C:/Project/
From the command prompt you should cd to the project folder, ie cd C:/Project/, now copy the cypress bin path as follows C:\Project\node_modules\.bin\ paste the path and then from there run the following command:
cypress run C:\Project\cypress\integration\examples\test-spec.js
note: This is tested and run in windows 10 environment
Related
When I update the cypress version from 9 to 10 and run the command "npx cypress open" unable to show my folder structure.
How have you named the specs in the folders?
If migrated from Cypress v9, change the spec extension to .cy.js and you should be able to pick them up.
Or change the configuration for specPattern to
specPattern: "cypress/e2e/**/*.spec.{js,jsx,ts,tsx}"
I have a small Angular app which I am try to build using gitlab-ci and node docker image, when I try to run the test using the command npm run test it fails with the following error :
ERROR [launcher]: No binary for Chrome browser on your platform. Please, set "CHROME_BIN" env variable.
gitlab-ci.yml
stages:
- build
variables:
NPM_CONFIG_REGISTRY: https://test.com/xx/api/npm/npm-all
build:
stage: build
image: node:12.9
script:
- npm install
- npm run build:prod
- npm run test
tags:
- DOCKER
In the above code npm run test executes ng test as configured in the package.json
I was able to run the build but when I run the test it looks for a chrome browser, I also tried running the test in a headless way using the below command but resulted in the same error :
ng test --no-watch --browsers=ChromeHeadless
How do I add the chrome feature to this build ?
Either install Chrome by yourself or try an existing Docker image that already includes it.
I have installed cypress using npm as npm install cypress --save-dev .
I used the same command in .gitlab-ci.yml file
When i run the command npm run cypress run locally , IDE opens and when i double click the spec.js file , then the tests run.
But I i use the same command on the gitlab pipeline , it says
cypress open "run"
It looks like this is your first time using Cypress: 4.1.0
[07:45:16] Verifying Cypress can run /osmc/ux/framework-acceptance-tests/cache/Cypress/4.1.0/Cypress [started]
[07:45:18] Verifying Cypress can run /osmc/ux/framework-acceptance-tests/cache/Cypress/4.1.0/Cypress [completed]
Opening Cypress...
and build fails .
Am i missing anything here ?
It's because it's opening the test runner, which is used locally via npx cypress open.
From that output it looks like you're running npx cypress open run, which isn't a real command and will open the runner
In CI you need to use npx cypress run, which will run tests without user interaction. https://docs.cypress.io/guides/guides/command-line.html#How-to-run-commands
Your gitlab.yml file should accomodate for the npm installations.
One example is as below. Meanwhile also please check the test/run command for your specs under package.json file. use the same command to trigger the test in pipeline.
stages:
- test
test:
image: cypress/browsers:node12.14.1-chrome85
stage: test
script:
npm i
npm run start:ci &
npx cypress run
You should have your .gitlab-ci.yml with:
stages:
- test
cypress-test:
image: cypress/browsers:node16.14.0-slim-chrome99-ff97
stage: test
script:
- npm ci
- npx cypress run
We're working on a small docker image container for windows to run a specflow test in a dotnet core projecct. The problem we have is that we can't get chromedriver to work as well as running the dotnet test command.
The specflow project we're running just contains one hello world testcase which we can run without chromedriver, but then we get the error message "OpenQA.Selenium.DriverServiceNotFoundException : The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable."
We're providing an instance of chromedriver in the project so we don't have to download it.
The dockerfile we're running:
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
WORKDIR /src
COPY . .
ENV PATH="/src/chromedriver:$PATH"
RUN dotnet test
We're using this command to run it: docker build . --build-arg HTTP_PROXY=http://PROXY:8080 --build-arg HTTPS_PROXY=http://PROXY:8080 --rm
We expect the specflow tests to run with chromedriver. When we run the dockerfile we get the error message "'dotnet' is not recognized as an internal or external command, operable program or batch file." It seems that the chromedriver is not added correctly to the PATH variable. We need it there to be able to run the specflow tests.
Does anybody know how to configure the dockerfile to work correctly with chromedriver?
Thanks for your time.
I'm running Mocha tests for React in Webstorm's terminal window using the following NPM start command:
"tsc && mocha --compilers js:babel-core/register --require ./test_helper.js \"test/**/*.#(js|jsx)\" --watch --watch-extensions js,jsx,tsx"
How do I create a Webstorm Mocha configuration so that I can run tests in Webstorm's test window?
Thanks.
Add a configuration for Mocha:
Run -> Edit Configurations -> Press "+" -> Select "Mocha".
Fields of the form:
Node interpreter: your_node_executable_path
Working directory: root_path_of_your_app
Mocha package: mocha_path (normally within your node_modules folder).
Test directory: root_path_of_your_app \test
By default Mocha looks the tests inside test folder and there, it tries to run test.js.
All the Mocha commands (--compilers, --require, etc) can be included in mocha.opts. Mocha tries to read this file in \test\mocha.opts.
mocha.opts requires one command per line.