Making the Test Pass
Explore how to make your JavaScript integration tests pass in a Rails environment by setting up Webpacker, managing dependencies with Yarn, and configuring jQuery. Understand how Rails 5.1 changed the JavaScript setup and learn to include JavaScript packs in your Rails layout. This lesson helps you build a foundation for effective JavaScript testing within Rails projects.
JavaScript environment
In this section, we’ll set up the JavaScript and present some passing code without unit testing. In the next chapter, we’ll set up JavaScript unit-testing tools and see how we might test-drive JavaScript features.
Rails 5.1 made two important changes to the JavaScript environment:
- jQuery is no longer a default dependency.
- Webpack integration is available via the Webpacker gem.
Webpack is an optional replacement for the Rails asset pipeline and has the same general purpose. It takes files that might be written in JavaScript, ...