Open Cypress browser when running from Jenkins - javascript

I created in Jenkins a freestyle project in which I wanted to run Cypress.
In the command line I used this command line:
npx cypress run --browser chrome --headed --spec "cypress/integration/examples/actions.spec.js" --config pageLoadTimeout=10000
The issue that it runs silent mode, there is no browser that is open, and perform test actions.
What should I do so that the browser appears while executing the test? Thanks in advance.

CI tools like Jenkins aren't designed to open browser.
That is why Cypress offers two ways to run it:
For local dev/debug: cypress open
For CI/automatisation : cypress run
You are using it the right way.
Interesting things for CI are screenshots and videos.

Yes, actually when you launch tests based on Cypress on CI (not only Jenkins) - you can't watch the process in debug mode.
Only on the local machine with the open parameter.
Also, save the video OR screenshots of running tests from Jenkins - and look after

Related

Can I host Cypress to a server?

So we're using Cypress + Cucumber to perform E2E UI tests. Everything is running fine, whenever I trigger the script, it shows the cypress pop-up, and I trigger a few tasks manually. Now we want our QA person to use the same prompt to test a few specific scenarios as they will. I know one way to trigger the test is during the CI/CD pipeline, but I was wondering if there's a way to host the app on some server, and a QA person can trigger a particular flow whenever they want.
So far I found cypress run --browser chrome --headed --no-exit --port 9000 command to keep the server active and run the tests when you click on it. But when I copy the URL and open it in another browser, I see an error saying that it can't run the test because the browser was not opened by cypress.
Please let me know if there's a way to achieve it.

No browser option displayed to select in Cypress tool dropdown even if the browsers are installed in local machine

I have installed Cypress version: 9.1.0, and I see only ELectron Browser as the default browser in the tool.
I have Google Chrome version 96.0 and Firefox installed in my local system but Cypress is unable to detect it. As I need to run the test on cross-browser only the Electron browser is displayed.
I tried to solve this issue as suggested in: Cypress 5.0 - Unable to find installed browsers
But still unable to resolve the issue and only Electron browser is shown in the tool as shown below:
when I tried to run the command npx cypress run --browser chrome it shows below error
I also tried running the command npx cypress open --browser "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
but got the below error:

Playwright - how to turn off PWDEBUG?

I have a simple question.
How to turn off the PWDEBUG on Playwright when running 'npx playwright test'
I have added a $env:PWDEBUG=1 in VS Terminal and all the time the tests are running into debugging mode. I just want the tests to run.
Any ideas?
You can unset the environment variable by the following command
$env:PWDEBUG=""
this should run the tests in normal mode.

Protractor + xvfb + selenium test Hangs on Jenkins

I'm having this issue sometimes on my automated tests running remotely on Jenkins. About 30% of the times.
The error:
Tests hangs after this line:
"I/launcher - Running 1 instances of WebDriver"
It gets stuck at this step indefinitely and I have to stop execution (manually) or wait to timeout to take control of it.
I tried several known solutions that i found on this site but nothing changed on my results.
My config:
Ubuntu OS 14.04.5 on a headless cloud storage system.
xvfb
Jenkins 1.656
selenium-server-standalone-2.53.1
chromedriver_2.24linux64
geckodriver-v0.9.0
nodejs v0.10.37
node v6.3.1
npm 3.10.3
protractor Version 4.0.9
grunt-cli v1.2.0
grunt v0.4.5
jasmine v2.5.2
jasmine-core v2.5.2
Jenkins Job Config:
Jenkins downloads my test project from github and runs the following commands on Project's shell:
node node_modules/grunt-cli/bin/grunt testName:parameters
(I don't want to run grunt globally, thats why i execute it in this way.)
Is there anything i can try in order to solve this hang issue?
Thanks in advance!

What's the right way to enable the node debugger with mocha's --debug-brk switch?

I have some debugger statements in my module under test and want to run mocha with --debug-brk set and hit my breakpoint so that I can inspect the state of my module. Unfortunately, whenever I run mocha with this option, I end up with a blank cursor on the next line. I can enter text, but there's nothing that appears to be processing my commands (it certainly doesn't look like the node debugger):
$ mocha --debug-brk tests.js -R spec
debugger listening on port 5858
[BLANK CURSOR]
Am I doing something wrong with how I'm launching mocha?
UPDATE
As of mocha 7.0.0, --debug-brk has been removed in favor of --inspect-brk
Using a recent version of nodejs (>=v6.3.0) and mocha (>=3.1.0), you can use V8 inspector integration.
V8 Inspector integration allows attaching Chrome DevTools to Node.js
instances for debugging and profiling
Usage
--inspect activates V8 inspector integration, and --debug-brk adds a breakpoint at the beginning. Since nodejs v7.6.0 and mocha v3.3.0, you can use the --inspect-brk shorthand for --inspect --debug-brk
$ mocha --debug-brk --inspect
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/remote/serve_file/#62cd277117e6f8ec53e31b1be58290a6f7ab42ef/inspector.html?experiments=true&v8only=true&ws=localhost:9229/node
With npm scripts
If you have a npm test script that uses mocha, you can pass the options from npm to your mocha script by using the end of option delimiter --:
$ npm test -- --inspect --debug-brk
Chrome tip
Instead of copy-pasting the url each time, go to chrome://inspect and click the appropriate link in the "Remote target" section.
To answer the original question, even though I also suggest you look into node-inspector: you can use the CLI debugger built into node through mocha with the debug option, instead of the --debug or --debug-brk flags. (Notice the lack of dashes.)
In your example, instead, it would be:
$ mocha debug tests.js -R spec
debugger listening on port 5858
connecting... ok
break in node_modules/mocha/bin/_mocha:7
5 */
6
7 var program = require('commander')
8 , sprintf = require('util').format
9 , path = require('path')
debug> [CURSOR]
Again, debug as above in bold, with no dashes. (=
Relevant: https://github.com/visionmedia/mocha/issues/247
I was able to get this to work using node-inspector. I run my test like you show in one shell:
mocha --debug-brk mocha/test.js
and then run node-inspector in a second shell:
node-inspector
Bringing up the URL that node-inspector spits out in a browser allows me to debug with the web inspector.
http://127.0.0.1:8080/debug?port=5858
If you have node-insector installed you can debug you Mocha tests without actually running node-inspector first. The easiest way is to
node-debug _mocha
That should start debugging the node tests in chrome (also works on Safari)
One reason I have seen that the tests do not work is sometimes you gave to try http://localhost:8080/debug?port=5858 or http://127.0.0.1:8080/debug?port=5858
run mocha with flag --inspect-brk and click 'open dedicated DevTools for node' in chrome from page chrome://inspect. In dedicated DevTools window add connection localhost:9229 to connect automatically.
Also add a debugger statement to the file you want debug.
(this is using latest versions of node and chrome as of October 2017)

Categories