Run Cypress without checking localhost for running web server - javascript

In addition to web based e2e tests, I am using Cypress to assert some graphql responses are correct.
However if I just try to run those tests on their own, with the web server not running, then Cypress complains with the following message;
Cypress could not verify that this server is running:
http://localhost:3000
This server has been configured as your baseUrl, and tests will likely fail if it is not running.
Is it possible to run Cypress in a mode that doesn't check this server first?

Related

Cypress Test Runner unexpectedly exited via a exit event with signal SIGSEGV in circleCI

I am stuck in this problem. I am running cypress tests. When I run locally, it runs smoothly. when I run in circleCI, it throws error after some execution.
Here is what i am getting:
[334:1020/170552.614728:ERROR:bus.cc(392)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[334:1020/170552.616006:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[334:1020/170552.616185:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[521:1020/170552.652819:ERROR:gpu_init.cc(441)] Passthrough is not supported, GL is swiftshader
Current behavior:
When I run my specs headless on the circleCI, Cypress closed unexpectedly with a socket error.
Error message:
The Test Runner unexpectedly exited via a exit event with signal
SIGSEGV
Please search Cypress documentation for possible solutions:
https://on.cypress.io
Platform: linux (Debian - 10.5)
Cypress Version: 8.6.0
Issue resolved by reverting back cypress version to 7.6.0.
I had this same issue on within our Azure builds as well. We only recently migrated from Cypress 8.4.0. Going back to that has solved the problem.
downgrade the cypress by running npm install cypress#7.6.0
Downgrade of cypress to 8.3.0 worked for me to solve that, you dont need to go to previous versions.
npm install cypress#8.3.0
SIGSEGV means a segmentation fault error. Read all about it here.
"In practice, a segfault occurs when your program breaks some
fundamental rule set by the operating system. In that case, the
operating system sends your process a signal (SIGSEGV on Mac & Linux,
STATUS_ACCESS_VIOLATION on Windows), and typically the process shuts
down immediately."
This blog post also goes into detail about how this can occur, even if you don't directly interact with the operating system (since we're writing JavaScript). Please read it on the original author's site for context.
But in short - you are likely encountering this error because
a. you upgraded Cypress while on an old version of NodeJS, or
b. you upgraded NodeJS, while you have Cypress code that is directly or indirectly incompatible (this could be your own code, or one of its dependencies) with that NodeJS version
Since SIGSEGV is a complete shutdown, you have no stack trace or debug information to guide you. So you have to debug the old fashioned way, turning tests and/or dependencies on or off to locate the problem in your code.

How do I debug server and client simultaneously in WebStorm?

I have a node.js app that runs a server and sends index.html. The index.html interacts with the server.
I want to debug the complete app, but when I debug the app, WebStorm only debugs the server.
Is this even possible in WebStorm? If not, are there other tools that can do this?
In the Node.js run configuration, Browser/Live Edit tab, specify the URL of your server, tick both After launch and with JavaScript debugger checkboxes - client-side debugger will be launched once you start your node server with this configuration, so that you will be able to debug both simultaneously, using a single run configuration.
See also https://www.jetbrains.com/help/webstorm/debugging-javascript-in-chrome.html#debugging_js_on_external_web_server for some hints on debugging client-side code run in browser

Running tests with 'ng e2e' is throwing 'Invalid host header'

I am executing protractor tests by executing ng e2e command, after running server on Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/
Then tests executes on localhost:4200 successfully, but when url changes to 'http://demo-qa.companyname.com:4200/' in 'protractor protractor.conf.js' as baseUrl, test failing while hitting the url with error 'Invalid Host error'
The same url when I type manually on browser it is working though. Not sure what I am missing,
I had also tried by providing protractor config parameter to pick config file after ng e2e command, final command looks like ng e2e --protractorConfig=e2e/protractor.conf.js , yet no luck. Any suggestions, on what I am missing.?

Stop a process by port from javascript

I'm using jest to write some tests for a node.js application. I have a server server.js and a test file server.test.js. In my server.js I use the line
var secureServer = https.createServer(options,
app).listen(config.node_port, () => {
logger.info("Service running on " + config.node_port)
});
to start my server on port 8082. In server.test.js I use
var posClient = require('./pos-ClientJS.js');
to get access to the functions, that I have to test. When I run my test I get the following console output:
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't
stopped in your tests. Consider running Jest with `--
detectOpenHandles` to troubleshoot this issue.
So my question is: Is there a way to stop the server running with javascript code like stop(8082) or sth.? Or is there a less difficult way to solve this problem without stopping the process?
From the Nodejs HTTP module documentation, you can call secureServer.close() to stop listening at the specified port. If the module exposes the server to Jest, you can use the teardown methods to stop the server automatically after tests complete.

How to browserify a Node.js WebSocket server?

Using examples from node-chromify I managed to run a Node.js Http server on a client side - inside a Chrome browser.
Then I tried to do exactly the same with a WebSocket server. Unfortunately I failed.
I think I tried most of the popular WebSocket libraries (npm modules) from Github.
While they work fine in configurations:
(a) both a WebSocket server and a WebSocket client are started from a Node command line
(b) the server runs from the command line and the client is included as a JavaScript in a html page (runs on a client side)
the scenario
(c) both the WebSocket server and the client running in a browser
is still unattainable for me so far.
During my attempts I tried the same approach by calling a command:
browserify server-ws.js -o bundle-server-ws.js
but when I included the generated bundle file into a html page I got always some critical errors regarding missing object definitions, etc.
In other words the above command seems not to bundle everything as the server code would expect during a runtime.
Should I use different switches/options during calling browserify?
Maybe it is not possible for browserify at all? For a client OK but with a server not...
I realize that migrating WebSocket stuff to the client side is much more complicated process than a regular npm module.
browserify v. 2.36.1
Node 0.10.22

Categories

Resources