-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Cypress could not verify that this server is running' error with baseUrl in component test after updating to v13 #27990
Comments
What is the Which version did you upgrade from? |
Previous version was 12.17.1 My project is an Angular nx monorepo. It is the basic command from nx to execute cypress component tests: project.json "component-test": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "libs/core/tables/cypress.config.ts",
"testingType": "component",
"skipServe": true,
"devServerTarget": "demo-app:build"
}
} |
But even with the cypress command I have the same output:
|
I am also getting this after upgrading to v13. If I replace |
@MetRonnie Could you share your config? Because for me it was not working |
Hmm does not work. |
(I get the "could not verify this server is running" message for both E2E and component tests, when I didn't before. It causes |
Possibly related to #25397? |
I'm seeing a similar issue, @MetRonnie Thanks, updating the interface ComponentConfigOptions<ComponentDevServerOpts = any> extends Omit<CoreConfigOptions, 'baseUrl' | 'experimentalStudio'> {
devServer: DevServerFn<ComponentDevServerOpts> | DevServerConfigOptions
devServerConfig?: ComponentDevServerOpts
/**
* Runs all component specs in a single tab, trading spec isolation for faster run mode execution.
* @default false
*/
experimentalSingleTabRunMode?: boolean
} |
I have the same issue after upgrading from Cypress 12.7.2 to 13.6.2. When I run the following command on Linux, I get:
The Interestingly enough, I can run component tests inside a cypress/browsers Docker image ... I don't know what the difference is yet. |
I found a clue! In
Then this issue is now similar to #25397, except here we don't even use a base URL, and nothing I tried so far helps as a workaround. |
@jennifer-shehane : I also reported this issue in #27967. I dont find any other workaround to resolve this issue as well. :( |
After few days of reading the Cypress source code and testing on our Azure server, I found that if ENV-variable HTTP_PROXY or HTTPS_PROXY is set, the server verification would fail. Row 59 in server/lib/util/ensure-url. ts function isListening: export const isListening = (urlStr: string) => {
// takes a urlStr and verifies the hostname + port is listening
let { hostname, protocol, port } = url.parse(urlStr)
if (port == null) {
port = protocol === 'https:' ? '443' : '80'
}
if (process.env.HTTP_PROXY) { <-- HERE
// cannot make arbitrary connections behind a proxy, attempt HTTP/HTTPS
// For some reason, TypeScript gets confused by the "agent" parameter
// and required double ts-ignore to allow it on local machines and on CI
// @ts-ignore
return rp({
url: urlStr,
// @ts-ignore
agent,
proxy: null,
})
.catch({ name: 'StatusCodeError' }, () => {}) // we just care if it can connect, not if it's a valid resource
}
return connect.getAddress(Number(port), String(hostname))
} |
@jennifer-shehane: I think there is a need to verify that the NO_PROXY settings are respected everywhere in the source code |
The issue is reproducible as well with Cypress version: 13.9.0 |
Add this line to your etc/hosts and maybe it will resolve your problem :) 127.0.0.1 localhost |
I have tried this already and unfortunately did not help. |
Any update on this @jennifer-shehane ? This issue has kept us from using the awesome cypress component testing and restricted us to still use only the e2e testing. Any eyes on this is greatly appreciated. Thanks |
Same here, do you have any updates? Sometimes it works (when the backend-Server spools up quickly), sometimes not. Would be nice if those end-2-end test would run a bit more reliable |
|
I was going to look into this because I thought it was easily reproducible, but in trying to reproduce it - I can't reproduce it with the information provided. I've been running Can someone provide an example or explain the other pieces needed to reproduce? My const { defineConfig } = require("cypress");
module.exports = defineConfig({
e2e: {
baseUrl: "http://localhost:3000",
setupNodeEvents(on, config) {},
},
component: {
devServer: {
framework: "react",
bundler: "webpack",
},
},
}); |
@jennifer-shehane Yes I can try to provide an example. I use cypress for e2e tests against a web application. I run Cypress in the Pipeline against a fully built App Container, which connects to a PostgreSQL Database Container. The App Container contains a Spring Boot App with the React Application in the static folder. My import { defineConfig } from 'cypress'
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:5173',
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
}) In the Pipeline, the App Container is built and thereafter the e2e tests are executed, stage('E2E tests'){
environment{
def currentDir = sh(returnStdout: true, script: 'pwd').trim()
VOLUME_DIR = currentDir.replace('/var/jenkins_home', '/volume2/docker/enterprise/jenkins')
}
steps{
script{
try{
sh 'docker-compose up --exit-code-from cypress'
}
catch(Exception e){
error("At least one e2e test failed: ${e.message}")
}
finally{
sh 'docker-compose down'
}
}
}
} And the version: '3'
services:
app-service:
image:app:${APP_VERSION}
depends_on:
- database
command: ['--spring.profiles.active=e2e']
cypress:
image: cypress/included:13.6.3
volumes:
- ${VOLUME_DIR}/app-ui:/e2e
depends_on:
- app-service
working_dir: /e2e
command:
[
'cypress',
'run',
'--browser',
'electron',
'--config',
'baseUrl=http://app-service:8080',
]
database:
image: postgres:15.2
environment:
- POSTGRES_USER=app-service
- POSTGRES_PASSWORD=end2endTest@App
- POSTGRES_DB=app-user So I override the baseUrl from the config with the docker-compose file. Since the Spring boot app has a database connected, the start of the application takes some time (database migrations scripts). Running the pipeline repeatedly, the e2e sometimes work, sometimes not. When they fail, the message |
@jennifer-shehane It might be setting |
@MetRonnie I'm not able to reproduce this issue when also setting the @AeroSecGeek This example you provided is functioning as intended. There will be an error if the server is not running when the e2e tests begin running. You need to ensure it is running before calling Cypress for e2e tests. This specific issue is about how this server running error displays when running COMPONENT tests - where this server is not required to run for CT tests and shouldn't be erroring at all. We'll need a reproducible example/repo of the original issue in order to investigate. |
@jennifer-shehane I don't know if using import dns from 'dns'
dns.setDefaultResultOrder('ipv4first') might affect it. We are doing this in our vite config to workaround #25397 Not really a minimal example, but you could try cloning https://github.com/cylc/cylc-ui and running
https://github.com/cylc/cylc-ui/blob/master/cypress.config.cjs |
@MetRonnie I got this repo up and running. The CT tests run without displaying a warning for me around 'Cypress could not verify that this server is running'. I commented out the |
@jennifer-shehane Hmm, not sure what else. I am on Node 20.16.0, don't know if there would be any difference at Node 22 if that's what you are on |
I think it is proxy related, as I cannot reproduce on my personal PC but can on my work machine |
we are facing similar issue while these tests on Jenkins using containers. For now we added a retry mechanism , retry has solved the problem , yet we are not able to figure out root cause . |
I have tried a retry mechanism, it doesn't fix the problem for me :( |
@LAURENS-Damien are you facing this issue while running tests on container ? Could you try few other recommendations ?
|
I was able to fix this issue by adding
|
thanks @beckiechoi, it fix my pipeline too ! @scsannalli yes the problem occured while i ran the tests on container. Maybe the |
Current behavior
In the UI it displays the warning "cannot connect base url"
But here it is possible to ignore and execute the tests.
With the CLI it fails:
Desired behavior
Before I updated it to version 13 it was working and it was not required to define the baseUrl for component tests. And the command
npx nx component-test core-tables
works without problemsTest code to reproduce
Cypress Version
13.2.0
Node version
v18.15.0
Operating System
Windows 10
Debug Logs
Other
nx version: 15.7.2
The text was updated successfully, but these errors were encountered: