-
Notifications
You must be signed in to change notification settings - Fork 25
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
Test fails when baseUrl in cypress.json in not included #59
Comments
and do you use full url to make a request, right? |
Hi @bahmutov yes, as per my example above using config files, it is structured like this:
The reason why I separate the different parts of the URI is because it changes from one environment to another. For example:
Again, this is not a big issue for me. It's just that the |
I'm getting the same problem too but only if I run the tests on the open mode with cypress. |
I'm relatively new to cypress and was seriously pulling my hair out over this because I hadn't set a base url in my config. Having a better error message would be helpful especially for newbies like myself. The main failure is on that first |
So what would be a good change here? Always require the base URL to be set before making |
I think that would be helpful, or at least if In my specific case, I'm using (nx)[https://nx.dev/] and the (Nx Serverless Plugin)[https://github.com/flowaccount/nx-plugins/tree/master/libs/nx-serverless], which doesn't pass a base url out as part of it's pipeline, so it needs to be manually populated in the config. Where as the angular pipeline provides a base url to the cypress command. |
Our project uses a similar wrapper/builder around cy.api to handle multiple baseUrls, so I'd prefer the 'real' baseUrl be left blank so that if someone forgets to use a fully qualified domain somewhere, they get a corresponding error.
The error happens in support.js here: const messagesEndpoint = Cypress._.get(
Cypress.env(),
'cyApi.messages',
'/__messages__'
)
// first reset any messages on the server
if (hasApiMessages) {
cy.request({
method: 'POST',
url: messagesEndpoint,
log: false,
failOnStatusCode: false // maybe there is no endpoint with logs
})
} When no baseUrl is set, When baseUrl IS set, it looks like a random request goes out to a likely non-existent endpoint. This seems... less than ideal. For example, if I set baseUrl to If I set my baseUrl to an arbitrary real webserver that has nothing to do with my tests (e.g. http://www.google.com), then everything works fine, but I'd much prefer avoiding setting baseUrl in the first place. Especially since it's sending out requests to |
Totally agree with @FFdhorkin . Cypress is just half-baked tool |
I use config files to switch between environment URL's. I have multiple URL's I need to initiate with as well on my different test suites. Hence, I am not using a specific
baseUrl
. However, ifbaseUrl
is not present incypress.json
, my tests fail. I had to include this variable with an actual value (e.g. https://loginsite.com) but will never use it.I understand it is not best practice, but switching between environments would require me with one environment 'http' and another having 'https' and multiple other reasons. Example:
This is just a minor issue but I would like a cleaner code and not include parameters/variables that are not being used.
The text was updated successfully, but these errors were encountered: