Cypress: Cypress.config('baseUrl') escapes slash

Created on 20 Feb 2019  路  6Comments  路  Source: cypress-io/cypress

Current behavior:

image

Desired behavior:

image

Steps to reproduce: (app code and test code)

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)
})

Versions

Windows, Cypress 3.1.5

bug

All 6 comments

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'))
})

screen shot 2019-02-20 at 11 23 15 pm

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

screen shot 2019-02-20 at 11 21 37 pm

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.

Was this page helpful?
0 / 5 - 0 ratings