Reputation: 24399
I am using React in my rails app with no problem. .jsx files are getting compiled properly. I can visit pages that use React components.
I have Jasmine set up and testing non-react files OK.
However, when I try to test a react component referenced as './hello.js' or './hello' in my application.js I get:
Uncaught Error: Sprockets::FileNotFound: couldn't find file './hello.js'
Recall, Sprockets finds this if I just run rails s
and visit a page that uses the component.
Why might this happen?
Upvotes: 2
Views: 1614
Reputation: 24399
Easy answer:
use jasmine-rails instead.
https://github.com/searls/jasmine-rails
Or a DIY solution:
Forget any gem.
Use the standalone Jasmine html and javascript and add it to the Rails project as a view that only renders in development mode.
The tests are run by visiting the page and access to the asset pipeline is as it would be in the app as long as the app is running.
Further, a js test/spec directory can be added to the asset path conditionally in development/test environments. See here. None of these files would be accessible in production.
Upvotes: 1