

cypress.json
{
"env": {
"test_url": "http://localhost:3000/"
},
"baseUrl": "http://localhost:3000/"
}
Example test:
it('test url', function () {
cy.visit('/')
var baseUrl = Cypress.config('baseUrl')
//baseUrl = baseUrl + '/' // bug in Cypress - add slash
cy.url().should('eq', Cypress.env('test_url'))
cy.url().should('eq', baseUrl)
})
Windows, Cypress 3.1.5
Duplicate of https://github.com/cypress-io/cypress/issues/2101
Sorry, this is not a duplicate at all. I read this assertion incorrectly.
The issue here is that the Cypress.config('baseUrl') is not evaluating to the correct value. The baseUrl value is http://localhost:3000/, but is evaluating as http://localhost:3000 in the test, removing the trailing slash.
I've confirmed this situation.
cypress.json
{
"baseUrl": "http://localhost:8080/"
}
test
it('test url', function () {
cy.visit('/')
cy.url().should('eq', Cypress.config('baseUrl'))
})

Also, the config in the Desktop GUI displays without the trailing slash as well.

I'm pretty sure a good deal of the baseUrl logic is contained in this file: https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cypress/location.coffee
The code for this is done in cypress-io/cypress#3546, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
Released in 3.2.0.