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

Cypress first run is restarting the test after cy.visit() when I am using a baseURL that is redirecting #27981

Closed
juanzuluagag opened this issue Oct 5, 2023 · 3 comments

Comments

@juanzuluagag
Copy link

juanzuluagag commented Oct 5, 2023

Current behavior

Video: https://drive.google.com/file/d/1HZbKUCGE2KbsxX3GvIQOIfWhD_W5e3n8/view?usp=sharing

My cypress.config.ts file has the following:

import { defineConfig } from "cypress";

export default defineConfig({
  e2e: {
    baseUrl: "http://www.google.com/",
    // baseUrl: "http://www.youtube.com/",
  },
  viewportHeight: 920,
  viewportWidth: 1366,
  defaultCommandTimeout: 5000,
  video: false,
  chromeWebSecurity: false,
});

When running cypress by yarn cypress open, I get in my console:

yarn run v1.22.18
warning ../../../../../../package.json: No license field
$ /Documents/Repo/node_modules/.bin/cypress open

DevTools listening on ws://127.0.0.1:61800/devtools/browser/fc104cf6-a0d5-4882-a41c-c1a02408744f
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped

Like if my baseURL was not configured.

When I try to run the test dummyTest.cy.ts

describe("Installing and Testing Cypress - Test Cases", () => {
    it("Dummy test - Navigate to BaseURL", () => {
        cy.visit("/");
    });
  });

Cypress start running, but when it reaches cy.visit(), starts the test again. (Only happens in the first run after opening Cypress and for baseURL that do some kind of redirection, like google in the example)

Desired behavior

  1. Cypress is not asking to configure a baseURL already configured
  2. Cypress does not refresh and stars over again the test when it reaches cy.visit()

Test code to reproduce

Already attached in actual behavior.

Cypress Version

v12.17.0

Node version

v18.17.0

Operating System

macOS 12.6.9

Debug Logs

No response

Other

No response

@jennifer-shehane
Copy link
Member

@juanzuluagag I watched the video. I believe this is happening because you have the non-secure http baseUrl for the google site, so it will redirect to the https url. For the youtube on, in the video - your baseUrl is already the secure https url. Does this issue persist when you switch google baseUrl to https to avoid that redirect?

@jennifer-shehane jennifer-shehane added the stage: awaiting response Potential fix was proposed; awaiting response label Oct 5, 2023
@juanzuluagag
Copy link
Author

juanzuluagag commented Oct 5, 2023

@jennifer-shehane Thanks for your answer. To provide some clarity:

1. What I am using in my code to set baseURL is the following:

baseUrl: "http://www.google.com/",
// baseUrl: "http://www.youtube.com/",

I do not really know why for youtube case, it is changed to https before the run.

2. Why my console is showing:

yarn run v1.22.18
warning ../../../../../../package.json: No license field
$ /Documents/Repo/node_modules/.bin/cypress open

DevTools listening on ws://127.0.0.1:61800/devtools/browser/fc104cf6-a0d5-4882-a41c-c1a02408744f
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped

If I already have a configured baseURL?

  1. If I change google url from http to https, the issue is not persisting. But for my "real" test where I need to set my baseUrl: "http://localhost:3000" (https not allowed here) which redirects to a https URL for safe login (auth0), the issue will persist.

@jennifer-shehane
Copy link
Member

Please try the latest version of Cypress. We fixed an issue with http -> https redirects that may have influenced this. Please open a new issue if you're encountering a similar issue.

@jennifer-shehane jennifer-shehane closed this as not planned Won't fix, can't repro, duplicate, stale Feb 29, 2024
@jennifer-shehane jennifer-shehane removed the stage: awaiting response Potential fix was proposed; awaiting response label Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants