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 loads wrong page on start #2891

Closed
davorbadrov opened this issue Dec 4, 2018 · 3 comments · Fixed by #3160
Closed

Cypress loads wrong page on start #2891

davorbadrov opened this issue Dec 4, 2018 · 3 comments · Fixed by #3160
Milestone

Comments

@davorbadrov
Copy link

davorbadrov commented Dec 4, 2018

Current behavior:

When I try to run cypress tests (the default examples that come after installing cypress) it starts the app properly, but the tests load the wrong page.
It doesn't load the Cypress test page inside the browser, it loads a html file I have in project.

The page that the browser opens is saved in <project_dir>/views/layout.html
whenever I run npx cypress open inside the project_dir.

The project directory looks like this:

→ tree
.
├── cypress
│   ├── fixtures
│   │   └── example.json
│   ├── integration
│   │   └── examples
│   │       ├── actions.spec.js
│   │       ├── aliasing.spec.js
│   │       ├── assertions.spec.js
│   │       ├── connectors.spec.js
│   │       ├── cookies.spec.js
│   │       ├── cypress_api.spec.js
│   │       ├── files.spec.js
│   │       ├── local_storage.spec.js
│   │       ├── location.spec.js
│   │       ├── misc.spec.js
│   │       ├── navigation.spec.js
│   │       ├── network_requests.spec.js
│   │       ├── querying.spec.js
│   │       ├── spies_stubs_clocks.spec.js
│   │       ├── traversal.spec.js
│   │       ├── utilities.spec.js
│   │       ├── viewport.spec.js
│   │       ├── waiting.spec.js
│   │       └── window.spec.js
│   ├── plugins
│   │   └── index.js
│   └── support
│       ├── commands.js
│       └── index.js
├── cypress.json
└── views
    └── layout.html

Inside of it I run npx cypress open.

The cypress app opens propery:

screen shot 2018-12-04 at 10 31 48

And this is what opens inside of the browser cypress opens when I run any of the example tests:

screen shot 2018-12-04 at 10 31 40

Cypress console output:

→ npx cypress open
GET /__/ 200 40.683 ms - 352
GET /favicon.ico 302 9.179 ms - 26
GET /__/ 304 8.686 ms - -
HEAD / 500 53.545 ms - -
HEAD / 500 51.452 ms - -
HEAD / 500 50.321 ms - -

Desired behavior:

I expected that it would load the cypress app with the list of tests on the left side and the content of a page open in the test runner to the right.

Steps to reproduce:

  1. Create a directory
  2. Inside it add views/layout.html with whatever content
  3. Inside the root directory run npx cypress open
  4. Run any of the cypress tests
  5. This opens views/layout.html for me

Versions

Issue happens on:

Cypress 3.1.2 and 3.1.3
OS: OSX El Capitan (10.11.6)
Browser: Chrome 70, Canary 73 and Electron 59

I can test it later in the day on my linux machine to confirm if it happens there as well.

Edit: Edited for clarity

@jennifer-shehane
Copy link
Member

I am able to reproduce this behavior. I created a repo that can be run to exhibit this behavior here: https://github.com/jennifer-shehane/weird-layout-bug/tree/master

@flotwig
Copy link
Contributor

flotwig commented Jan 17, 2019

It looks like something to do with the way Express handles views. Express's default setting for 'views' is the 'views' directory. I noticed that this error occurs if you have a file named 'views/layout.html', but not if you have a file named 'views/layout2.html'.

If you do app.set("views", "__CY_THIS_DIR_WILL_NEVER_EXIST") while setting up the Cypress Express app, this issue no longer occurs, and I have an open PR for that at #3160. However, I'm still not sure exactly why this is happening at all.

@lilaconlee lilaconlee removed their assignment Jan 17, 2019
@jennifer-shehane jennifer-shehane added stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope labels Jan 18, 2019
@jennifer-shehane jennifer-shehane added stage: needs a test and removed stage: needs review The PR code is done & tested, needs review labels Jan 18, 2019
@flotwig flotwig added stage: needs review The PR code is done & tested, needs review and removed stage: needs a test labels Jan 22, 2019
@jennifer-shehane jennifer-shehane modified the milestones: Sprint 15, Sprint 20 Jan 23, 2019
chrisbreiding pushed a commit that referenced this issue Jan 23, 2019
Fixes #2891

Not sure that this won't have an adverse impact, also not sure if there's a cleaner way to accomplish this fix
@jennifer-shehane jennifer-shehane added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Jan 23, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 30, 2019

Released in 3.1.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants