I have a coffee
class which is called in the create.js.coffee
file. It works fine on development.
However when running feature tests (with Capybara
and web-kit
), it seems that this class isn't getting loaded properly.
These are the files:
assets/javascript/app_init.js.coffee
window.MyApp = { }
assets/javascript/modules/product_module.js.coffee
window.MyApp.ProductModule = class ProductModule
@show: ->
# Do stuff
assets/javascript/application.js
//= require app_init
//= require_tree .
And the create.js.coffee
console.log window.MyApp => Returns [Object Object]
console.log window.MyApp.ProductModule => Returns undefined
These returns are what I get when running the specs and debugging. Any ideas?
I am using Rails 5 if that helps
I run
rails assets:precompile
and it fixed the tests. I am not sure why I needed to precompile assets to run the test. I might have something wrong at the configuration. Ideas?