Closed VadymBoguslavsky closed 2 years ago
i see it's returning a 404
status ... maybe it can't find the clean.rb
file. Is clean.rb
still in the cypress/app_commands
folder?
Yes. clean.rb
is still there.
I have tried to remove if
in cypress AppCommands
Cypress.Commands.add('appCommands', function (body) {
Object.keys(body).forEach(key => body[key] === undefined ? delete body[key] : {});
const log = Cypress.log({ name: "APP", message: body, autoEnd: false })
return cy.request({
method: 'POST',
url: "/__cypress__/command",
body: JSON.stringify(body),
log: false,
failOnStatusCode: false
}).then((response) => {
log.end();
return response.body
});
});
And logically there is no error anymore. but after that i discovered that clean.rb
, and other commands that defined in app commands like appFactories
or appScenarios
not working and i cant understand why.
Also i define and use it like :
beforeEach(() => {
cy.app('clean') // have a look at cypress/app_commands/clean.rb
cy.app('basic');
cy.appScenario('everything_active')
})
it('setup basic scenario', function() {
cy.app('basic');
cy.visit('/')
cy.appFactories([
['create_list', 'ad', 10],
['create', 'ad', {title: 'erfreerfr'} ],
])
cy.appFactories([['create', 'ad', {price: 234, featured: true}]])
And my scenario is
user = User.create!(email: 'user1@test.com',name: 'user1')
shop = Shop.create!(:shop, user: user)
invoice = Invoice.create!(:invoice, target: shop)
Ad, shop, invoice already defined in factorybot.
hmmm, i guess the other possibility is that the middleware is not enabled and that is why you are getting a 404
error.
in you cypress_on_rails.rb
initializer is use_middleware
set to true?
yes, this is my cypress_on_rails.rb
file
if defined?(CypressOnRails)
CypressOnRails.configure do |c|
c.cypress_folder = File.expand_path("#{__dir__}/../../cypress")
# WARNING!! CypressOnRails can execute arbitrary ruby code
# please use with extra caution if enabling on hosted servers or starting your local server on 0.0.0.0
c.use_middleware = true
c.logger = Rails.logger
end
# # if you compile your asssets on CI
# if ENV['CYPRESS'].present? && ENV['CI'].present?
# Rails.application.configure do
# config.assets.compile = false
# config.assets.unknown_asset_fallback = false
# end
# end
end
Can you share the output of the browser console when you click on "Print to console" please.
Its an error with default test using_scenarios
You should be able to expand the "Applied to" output in the printed console output. That is the body of the http request. Hopefully you can see something in it that can be a clue on why it's not working. Feel free to share it here as well.
Can you share the full "Response Body" please
What can i do to fix this error? All i have done is installed cypress-on-rails and run it locally
It seems that something failed in the appCommands function