{"id":21633,"date":"2018-05-11T12:15:25","date_gmt":"2018-05-11T09:15:25","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=21633"},"modified":"2018-05-10T14:04:04","modified_gmt":"2018-05-10T11:04:04","slug":"rails-frontend-testing-with-javascript-insights","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/","title":{"rendered":"Rails Frontend Testing with JavaScript Insights"},"content":{"rendered":"<p>One of the newer things that Rails 5+ provides is <em>system tests<\/em>. This gives us a full frontend testing experience with Capybara, which runs each of our tests through a real browser window to perfectly provide what a normal web user would experience. Having this baked in to Rails makes for an elegant way to get started and hit the ground running.<\/p>\n<p>What\u2019s more, Rails will generate our standard CRUD system tests per resource when we use the Rails generator to generate it with the models name and attribute fields. This makes swapping in frontend frameworks a much more seamless experience.<\/p>\n<p>In this post, we\u2019ll tackle what changes to the code are required to get <a href=\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/\">our previous Rails and VueJS posts app<\/a> system tests all passing. And we\u2019ll look at some JavaScript insights that might just save your day.<\/p>\n<h2>Updating a Frontend Application<\/h2>\n<p>The changes we\u2019ll be demonstrating here are from where we left off in the <a href=\"https:\/\/www.webcodegeeks.com\/javascript\/vuejs-components-with-coffeescript-for-rails\/\">VueJS Components with CoffeeScript for Rails<\/a> post. You can find the source code for where we left off at <a href=\"https:\/\/github.com\/danielpclark\/vue_example\/tree\/SecondBlogVersion\">danielpclark\/vue_example<\/a>.<\/p>\n<p>To run your system tests, execute the following command in your project directory:<\/p>\n<pre class=\"brush:php\">rails test:system<\/pre>\n<p>We should have two errors showing up for our create and update resources. The error message reads <code>Unable to find visible field \"Body\" that is not disabled<\/code>.<\/p>\n<p>We get the error about only this field because it\u2019s the first error that\u2019s come across in the test. If we swap our test order around, we\u2019ll find that all of our fields in the create and update tests fail in this way. This has to do with the way Capybara looks up fields for testing.<\/p>\n<p>When you use Rails\u2019 form methods to generate labels and input fields, the HTML element <code>label<\/code> will have a <code>for<\/code> field. This contains the name of whatever input\u2019s <code>id<\/code> object you\u2019re targeting. When we wrote a new form by hand with our VueJS components template, we didn\u2019t write these fields in. So you\u2019ll need to change the form fields in file <code>app\/javascript\/form-document.vue.erb<\/code> from:<\/p>\n<pre class=\"brush:xml\">&lt;label&gt;Subject&lt;\/label&gt;\r\n&lt;input type=\"text\" v-model=\"document.subject\" \/&gt;\r\n\r\n&lt;label&gt;State&lt;\/label&gt;\r\n&lt;select v-model=\"document.state\"&gt;\r\n  &lt;%= options_for_select(Document.states.keys, \"concept\") %&gt;\r\n&lt;\/select&gt;\r\n\r\n&lt;label&gt;Body&lt;\/label&gt;\r\n&lt;textarea v-model=\"document.body\"&gt;&lt;\/textarea&gt;<\/pre>\n<p>to the following:<\/p>\n<pre class=\"brush:xml\">&lt;label for=\"document_subject\"&gt;Subject&lt;\/label&gt;\r\n&lt;input id=\"document_subject\" type=\"text\" v-model=\"document.subject\" \/&gt;\r\n\r\n&lt;label for=\"document_state\"&gt;State&lt;\/label&gt;\r\n&lt;select id=\"document_state\" v-model=\"document.state\"&gt;\r\n  &lt;%= options_for_select(Document.states.keys, \"concept\") %&gt;\r\n&lt;\/select&gt;\r\n\r\n&lt;label for=\"document_body\"&gt;Body&lt;\/label&gt;\r\n&lt;textarea id=\"document_body\" v-model=\"document.body\"&gt;&lt;\/textarea&gt;<\/pre>\n<p>Now when you ask Capybara to <code>fill_in<\/code> the <code>Subject<\/code>, it gets the target by the label\u2019s content and <code>for<\/code> value and then targets the <code>id<\/code> used in that <code>for<\/code> value. What\u2019s nice about this is you may use this label targeting technique in ways other than targeting an input field that follows.<\/p>\n<p>If you try to run <code>rails test:system<\/code> again, you\u2019ll notice the same error messages are coming up. This has to do with a configuration in Rails 5 where the test environment isn\u2019t using <code>protect_from_forgery<\/code>, so the CSRF token is not being provided. Our VueJS code is failing because it explicitly requires that meta attribute field to be available.<\/p>\n<p>You can fix this in one of these ways:<\/p>\n<ul>\n<li>Change your VueJS code so that it can work without a CSRF token present <em>(which I advise against)<\/em>.<\/li>\n<li>Change your <code>config\/environments\/test.rb<\/code> file to have the following:<\/li>\n<\/ul>\n<pre class=\"brush:js\"># Forgery protection\r\nconfig.action_controller.allow_forgery_protection = true<\/pre>\n<p>The following line of code may be required in your <code>ApplicationController<\/code> for some frontend form submission implementations to work. For our use case, we won\u2019t need it now:<\/p>\n<pre class=\"brush:js\">protect_from_forgery prepend: true<\/pre>\n<blockquote><p>To discover why this issue occurred, you need to run <code>rails server<\/code> with the <code>RAILS_ENV=test<\/code> set. You can then see the JavaScript errors occurring in the browser\u2019s console when you visit the <code>new<\/code> and <code>edit<\/code> resource for our Document resource.<\/p><\/blockquote>\n<p>Now when you run <code>rails test:system<\/code>, the test error message has changed, saying the buttons <em>Update Document<\/em> and <em>Create Document<\/em> cannot be found. That\u2019s the naming scheme Rails would have generated for the submission button had we used their form helpers, so we\u2019ll need to update the tests to reflect our current button\u2019s name.<\/p>\n<p>Open up <code>test\/system\/documents_test.rb<\/code> and change the <code>click_on<\/code> target from <code>\"Create Document\"<\/code> and <code>\"Update Document\"<\/code> to <code>\"Submit\"<\/code>. Now running the tests, we get a new message saying the proper flash notification wasn\u2019t found in the returned result. We\u2019ll need to add in the flash messages by adding the following to our application template <code>app\/views\/layouts\/application.html.erb<\/code> just inside the <code>&lt;body&gt;<\/code> tag:<\/p>\n<pre class=\"brush:xml\">&lt;% flash.each do |name, msg| -%&gt;\r\n  &lt;%= content_tag :div, msg, class: name %&gt;\r\n&lt;% end -%&gt;<\/pre>\n<p>And then updating our controller\u2019s update and new actions to have the appropriate flash notice in <code>app\/controllers\/documents_controller.rb<\/code>:<\/p>\n<pre class=\"brush:js\">def create\r\n  @document = Document.new(document_params)\r\n\r\n  respond_to do |format|\r\n    if @document.save\r\n      flash[:notice] = 'Document was successfully created.'\r\n      format.html { redirect_to @document, notice: 'Document was successfully created.' }\r\n      format.json { render :show, status: :created, location: @document }\r\n    else\r\n      format.html { render :new }\r\n      format.json { render json: @document.errors, status: :unprocessable_entity }\r\n    end \r\n  end \r\nend\r\n\r\ndef update\r\n  respond_to do |format|\r\n    if @document.update(document_params)\r\n      flash[:notice] = 'Document was successfully updated.'\r\n      format.html { redirect_to @document, notice: 'Document was successfully updated.' }\r\n      format.json { render :show, status: :ok, location: @document }\r\n    else\r\n      format.html { render :edit }\r\n      format.json { render json: @document.errors, status: :unprocessable_entity }\r\n    end \r\n  end \r\nend<\/pre>\n<p>And at this point, running <code>rails test:system<\/code>, all our system tests will pass.<\/p>\n<h2>JavaScript Insights for Rails<\/h2>\n<p>Many Rails developers may not have a good grasp on JavaScript and its behavior when things go wrong. And in Rails, there are additional things that change its behavior in a peculiar way.<\/p>\n<p>You may have heard many people express their dislike for Turbolinks and\/or Spring. I happen to like both of these technologies, but if you don\u2019t know what they do for you, they may lead even the most experienced JavaScript developers scratching their heads.<\/p>\n<p>Let\u2019s have a brief description of these two libraries.<\/p>\n<p><strong>Turbolinks<\/strong> is a tool that loads pages more quickly and provides a few quick-load UJS features for forms and some CRUD actions. The introduction of Turbolinks does change the JavaScript page ready hook you would normally use to <code>\"turbolinks:load\"<\/code>. Using the standard JavaScript page ready hook causes issues when Turbolinks is in use.<\/p>\n<p><strong>Spring<\/strong> is a preloader for code in your application. It will load both Ruby code and frontend assets in its own process and cache what\u2019s loaded to be available by the next request. If you don\u2019t know how JavaScript handles errors, this can lead you to try to track down a bug for many days, as Spring will have things work after the first navigation from the first page load. So when the site loads, some things may seem not to work, but then you click a link and it starts working.<\/p>\n<p>Let\u2019s take a look first at how JavaScript handles bad code before delving in to Spring\u2019s role in it.<\/p>\n<p>When JavaScript comes across some bad code, or anything that evaluates to something it shouldn\u2019t, JavaScript stops what it\u2019s doing and produces some output in your browser\u2019s console indicating that something is wrong. So when you introduce a new JavaScript library to your application and it has some bad code, then anything that follows it in your code, whether it\u2019s more libraries or your own code, won\u2019t run. This is the normal JavaScript behavior, to stop code execution at a point of bad code evaluation.<\/p>\n<p>But when you add in Spring, which will load your assets in to a cache <em>(with Turbolinks)<\/em>, Spring doesn\u2019t avoid JavaScript code after bad JavaScript code evaluation. So you load the first page and Spring\/Turbolinks caches your assets and libraries for faster load.<\/p>\n<p>By the time you navigate through the first link, you may not see that anything is wrong because Spring produces the good JavaScript code after the bad. If a JavaScript feature isn\u2019t needed on the first page load, then unless you\u2019re looking for a problem in the console, you may not know anything is wrong. And when you go to publish your work, all of a sudden the site is partially down and not behaving as you expected even though \u201cit works on my machine.\u201d<\/p>\n<p>This kind of thing has likely led many people to pull their hair out over not getting the same results on their machine as in production.<\/p>\n<p>A good tip for JavaScript developers is that any time you add a new library or new JavaScript code to your application, put a simple <code>console.log(\"Seems okay \u00af\\_(\u30c4)_\/\u00af\");<\/code> right after it. Then in your browser console, make sure that the code gets that far. Once you see the console log the output, you know that your JavaScript code didn\u2019t come across any bad evaluation of code when loading.<\/p>\n<p>I had tried a version of the Bootstrap 4 library, which has some bad JavaScript code evaluation in it, and I had placed it before the other JavaScript libraries were required in one of my applications. This caused all of the JavaScript related code not to work on the first page load but then appear to work on refresh and after the first link navigation. Because I had put it before Turbolinks that code was also behaving in this manner. To get it to work with Spring on the first page load, I put together this little hack in CoffeeScript:<\/p>\n<pre class=\"brush:js\">if !Turbolinks?\r\n  location.reload\r\n\r\nTurbolinks.dispatch(\"turbolinks:load\")<\/pre>\n<p>This of course makes it work on my machine but won\u2019t work in production. Developers in Rails often run into situations where the <code>\"turbolinks:load\"<\/code> trigger isn\u2019t called the first time the website\u2019s first page loads.<\/p>\n<p>The <code>Turbolinks.dispatch(\"turbolinks:load\")<\/code> is the way to instantly trigger that web hook as soon as that line of JavaScript is evaluated. This will come in handy for anyone who needs to get this to occur on first page load of their JavaScript\/CoffeeScript scripts.<\/p>\n<p>Triggering CoffeeScript on page load normally requires a little extra work since all CoffeeScript code is wrapped in a function and its scope is protected. Using the <code>Turbolinks.dispatch(\"turoblinks:load\")<\/code> method makes this not so complicated.<\/p>\n<p><code>if !Turbolinks?; location.reload<\/code> is only a useful hack for when Spring is in use. It\u2019s only needed to load JavaScript code in your development environment despite some bad JavaScript code evaluation occurring. Instead of using it, just use the <code>console.log<\/code> technique to see how far your JavaScript code has successfully executed. Then remedy the bad code evaluation situation.<\/p>\n<h2>Summary<\/h2>\n<p><a href=\"http:\/\/teamcapybara.github.io\/capybara\/\">Capybara<\/a> is a nice library for simple-to-write tests that work with your full frontend experience. Rails generates most of the proper Capybara tests for you so you can read the tests that are there and continue writing similar tests with what you learned from there. Rails does the heavy lifting of configuration and defaults so it\u2019s very easy to get started with frontend testing.<\/p>\n<p>Another additional nicety in Rails 5 is that whenever there is an exception raised in a system test, it captures a screenshot of the browser window\u2019s contents and saves it to <code>tmp\/screenshots\/<\/code>. Now you can see what\u2019s on the screen and compare it to your test to better determine what\u2019s wrong with it.<\/p>\n<p>With an understanding of how JavaScript behaves with Rails\u2019 libraries, we can prevent lots of debugging time we would otherwise get stuck with. This further increases our ability to use these powerful tools that have jaded others. <a href=\"https:\/\/github.com\/turbolinks\/turbolinks\">Turbolinks<\/a> and <a href=\"https:\/\/github.com\/rails\/spring\">Spring<\/a> make for a wonderful experience once you understand their effects and how to take advantage of them.<\/p>\n<p>It feels good to be a Rails developer these days. Enjoy frontend testing!<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>Published on Web Code Geeks with permission by Daniel P. Clark, partner at our <a href=\"\/\/www.webcodegeeks.com\/join-us\/wcg\/\" target=\"_blank\" rel=\"noopener\">WCG program<\/a>. See the original article here: <a href=\"https:\/\/blog.codeship.com\/rails-frontend-testing\/\" target=\"_blank\" rel=\"noopener\">Rails Frontend Testing with JavaScript Insights<\/a><\/p>\n<p>Opinions expressed by Web Code Geeks contributors are their own.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>One of the newer things that Rails 5+ provides is system tests. This gives us a full frontend testing experience with Capybara, which runs each of our tests through a real browser window to perfectly provide what a normal web user would experience. Having this baked in to Rails makes for an elegant way to &hellip;<\/p>\n","protected":false},"author":146,"featured_media":4127,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[95,121],"class_list":["post-21633","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-rails","tag-testing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Rails Frontend Testing with JavaScript Insights - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"One of the newer things that Rails 5+ provides is system tests. This gives us a full frontend testing experience with Capybara, which runs each of our\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Rails Frontend Testing with JavaScript Insights - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"One of the newer things that Rails 5+ provides is system tests. This gives us a full frontend testing experience with Capybara, which runs each of our\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-11T09:15:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Daniel P. Clark\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel P. Clark\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/\"},\"author\":{\"name\":\"Daniel P. Clark\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a79c83c57cba5d8a6e46462149890b5e\"},\"headline\":\"Rails Frontend Testing with JavaScript Insights\",\"datePublished\":\"2018-05-11T09:15:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/\"},\"wordCount\":1746,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\",\"keywords\":[\"Rails\",\"Testing\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/\",\"name\":\"Rails Frontend Testing with JavaScript Insights - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\",\"datePublished\":\"2018-05-11T09:15:25+00:00\",\"description\":\"One of the newer things that Rails 5+ provides is system tests. This gives us a full frontend testing experience with Capybara, which runs each of our\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Rails Frontend Testing with JavaScript Insights\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a79c83c57cba5d8a6e46462149890b5e\",\"name\":\"Daniel P. Clark\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2342ad14824a1064823dcec81641a12136a3492abae522e473ec723cbfb84bce?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2342ad14824a1064823dcec81641a12136a3492abae522e473ec723cbfb84bce?s=96&d=mm&r=g\",\"caption\":\"Daniel P. Clark\"},\"description\":\"Daniel P. Clark is a freelance developer, as well as a Ruby and Rust enthusiast. He writes about Ruby on his personal site.\",\"url\":\"https:\/\/www.webcodegeeks.com\/author\/daniel-clark\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Rails Frontend Testing with JavaScript Insights - Web Code Geeks - 2026","description":"One of the newer things that Rails 5+ provides is system tests. This gives us a full frontend testing experience with Capybara, which runs each of our","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/","og_locale":"en_US","og_type":"article","og_title":"Rails Frontend Testing with JavaScript Insights - Web Code Geeks - 2026","og_description":"One of the newer things that Rails 5+ provides is system tests. This gives us a full frontend testing experience with Capybara, which runs each of our","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2018-05-11T09:15:25+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","type":"image\/jpeg"}],"author":"Daniel P. Clark","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Daniel P. Clark","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/"},"author":{"name":"Daniel P. Clark","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a79c83c57cba5d8a6e46462149890b5e"},"headline":"Rails Frontend Testing with JavaScript Insights","datePublished":"2018-05-11T09:15:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/"},"wordCount":1746,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","keywords":["Rails","Testing"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/","name":"Rails Frontend Testing with JavaScript Insights - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","datePublished":"2018-05-11T09:15:25+00:00","description":"One of the newer things that Rails 5+ provides is system tests. This gives us a full frontend testing experience with Capybara, which runs each of our","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/rubyonrails-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/rails-frontend-testing-with-javascript-insights\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Rails Frontend Testing with JavaScript Insights"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/a79c83c57cba5d8a6e46462149890b5e","name":"Daniel P. Clark","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2342ad14824a1064823dcec81641a12136a3492abae522e473ec723cbfb84bce?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2342ad14824a1064823dcec81641a12136a3492abae522e473ec723cbfb84bce?s=96&d=mm&r=g","caption":"Daniel P. Clark"},"description":"Daniel P. Clark is a freelance developer, as well as a Ruby and Rust enthusiast. He writes about Ruby on his personal site.","url":"https:\/\/www.webcodegeeks.com\/author\/daniel-clark\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/21633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/146"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=21633"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/21633\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/4127"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=21633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=21633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=21633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}