Does not seem to work in an initial Rails app?
Closed this issue · 1 comments
spilth commented
I realize this is probably an edge case, but I tried to set up a Rails project with the minimal Cypress integration by checking that the root path serves up the default "Yay!" Rails page. I was surprised to get a 500 error but also suspect most folks will never try to write this test.
Here is a repo that shows the issue: https://github.com/spilth/cypress-rails-test
And here are instructions to replicate from scratch:
$ ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20
$ rails new cypress-rails-test
$ cd cypress-rails-test
$ bin/setup
$ yarn add --dev cypress
$ bundle add cypress-rails --group "development,test"
$ bundle install
$ rake cypress:init
$ mkdir -p cypress/integration
Create cypress/integration/homepage.spec.js
with the following contents:
/// <reference types="cypress" />
context('Homepage', () => {
it('displays the rails message', () => {
cy.visit('/')
cy.get('h1').should('have.text', 'Yay! You’re on Rails!')
})
})
Then run Cypress:
$ rake cypress:run
...
Homepage
2020-12-27 13:53:50 -0600 Rack app ("GET /" - (127.0.0.1)): #<ActionController::RoutingError: No route matches [GET] "/">
1) displays the rails message
0 passing (1s)
1 failing
1) Homepage
displays the rails message:
CypressError: `cy.visit()` failed trying to load:
http://127.0.0.1:64955/
The response we received from your web server was:
> 500: Internal Server Error
This was considered a failure because the status code was not `2xx`.
And if you run Cypress via rake cypress:open
and try to visit the root page, it displays the following:
An unhandled lowlevel error occurred. The application logs may have details.
searls commented
Yeah, this is probably because that route only renders in RAILS_ENV=development
, IIRC.