Skip to content
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

Prevent test reload when not setting baseUrl #2602

Closed
rsmets opened this issue Oct 12, 2018 · 4 comments
Closed

Prevent test reload when not setting baseUrl #2602

rsmets opened this issue Oct 12, 2018 · 4 comments
Labels
stage: wontfix Cypress does not regard this as an issue or will not implement this feature type: unexpected behavior User expected result, but got another

Comments

@rsmets
Copy link

rsmets commented Oct 12, 2018

Current behavior:

Upon first opening a test using the test runner some test are run then the browser reloads and all but the first test is reran which is what the dashboard reads as the result. This behavior is only noticeable when the first test group contains a network request. This stutter step, so to speak, has had averse effects on tests as one can imagine.

Desired behavior:

Upon first opening the tests are run once with no reload / restart.

Steps to reproduce:

Below is example code to reproduce. Upon clicking on the bug example file in the test runner please quickly open the console with preserve log checked to view the characteristic. Note 'randomString2' and 'in request response' is never logged. To reproduce again one must close the browser, stop the test, and restart the test forcing the browser to open for first time.

var randomstring = require("randomstring");

var randomString;
describe('bug highlight', function () {
  before(function () { 
    randomString = randomstring.generate();
    console.log('randomString1', randomString);
  })

  context('bug', function () {
    it('post', () =>{
        console.log('randomString2', randomString);
        return cy.request({
            method: 'POST',
            url: `https://e.deployads.com/e/whatismyip.com`,
            form: false,
            body: {"jsr":{"_count":1,"bdl":"7133","msg":"Okay","u":"https://www.whatismyip.com/what-is-my-public-ip-address/","pv":`${randomString}`,"sid":"jn6d3c0k2juz91","r":"https://www.google.com/","sta":200,"tas":1539368968738,"bld":17252,"s":"whatismyip.com","uid":"jn6d3c0k2juz91","typ":"im","cfdt":"D","rt":115,"_type":"jsr"}}
        }).then((response) => {
            console.log('in request response');
            cy.expect(response.status).to.eq(200);
        })
    })

    it('visit', () =>{
        console.log('randomString3', randomString);
        cy.visit('https://google.com');
    })
  })
})

Versions

cypress v3.1.0
chrome canary 71

@rsmets rsmets changed the title Test Load then Reloaded Upon First Opening Load then Unexplainable Reloaded Upon Test Suite First Opening Oct 12, 2018
@rsmets rsmets changed the title Load then Unexplainable Reloaded Upon Test Suite First Opening Load then Unexplainable Reloaded Upon Test Run Oct 12, 2018
@jennifer-shehane
Copy link
Member

You can prevent the reload by setting a baseUrl. The explanation for the reload is explained more here: https://on.cypress.io/best-practices#Setting-a-global-baseUrl

@rsmets
Copy link
Author

rsmets commented Oct 12, 2018

Hi @jennifer-shehane thanks for the prompt reply. I actually almost posted this at the bottom of #1541 stating that I have to leave the baseUrl config prop blank due to it not following proxy settings on my CI box. Thus using a env variable serving the same purpose(ish).

@jennifer-shehane jennifer-shehane added the stage: needs investigating Someone from Cypress needs to look at this label Dec 11, 2018
@jennifer-shehane jennifer-shehane changed the title Load then Unexplainable Reloaded Upon Test Run Prevent test reload when not setting baseUrl Feb 14, 2019
@jennifer-shehane jennifer-shehane added stage: proposal 💡 No work has been done of this issue type: unexpected behavior User expected result, but got another and removed stage: needs investigating Someone from Cypress needs to look at this labels Jul 24, 2019
@rbayliss
Copy link

It looks like this also happens when baseUrl is set and you cy.visit() any domain that is not the same as the baseUrl.

@flotwig
Copy link
Contributor

flotwig commented Jul 31, 2020

@rbayliss this is expected behavior so Cypress can exist within the browser's security model, see explanation here: https://docs.cypress.io/guides/references/best-practices.html#Setting-a-global-baseUrl


Hi @jennifer-shehane thanks for the prompt reply. I actually almost posted this at the bottom of #1541 stating that I have to leave the baseUrl config prop blank due to it not following proxy settings on my CI box. Thus using a env variable serving the same purpose(ish).

@rsmets Cypress has had proxy support for about a year now, might be worth trying baseUrl again


Closing this issue as wontfix

@flotwig flotwig closed this as completed Jul 31, 2020
@flotwig flotwig added the stage: wontfix Cypress does not regard this as an issue or will not implement this feature label Jul 31, 2020
@cypress-io cypress-io locked as resolved and limited conversation to collaborators Jul 31, 2020
@jennifer-shehane jennifer-shehane removed the stage: proposal 💡 No work has been done of this issue label Aug 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stage: wontfix Cypress does not regard this as an issue or will not implement this feature type: unexpected behavior User expected result, but got another
Projects
None yet
Development

No branches or pull requests

4 participants