<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Testing on Jake Worth</title><link>https://jakeworth.com/tags/testing/</link><description>Recent content in Testing on Jake Worth</description><image><title>Jake Worth</title><url>https://jakeworth.com/twittercard.png</url><link>https://jakeworth.com/twittercard.png</link></image><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 21 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://jakeworth.com/tags/testing/index.xml" rel="self" type="application/rss+xml"/><item><title>Writing the DOM with fs</title><link>https://jakeworth.com/tils/writing-the-dom-with-fs/</link><pubDate>Fri, 30 Jan 2026 11:12:52 -0500</pubDate><guid>https://jakeworth.com/tils/writing-the-dom-with-fs/</guid><description>&lt;p&gt;How can I output the entire DOM to a file in a JavaScript test?&lt;/p&gt;</description></item><item><title>Custom Ipsum for Real-World Testing</title><link>https://jakeworth.com/posts/custom-ipsum-for-real-world-testing/</link><pubDate>Fri, 27 Jun 2025 16:00:28 -0400</pubDate><guid>https://jakeworth.com/posts/custom-ipsum-for-real-world-testing/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Pastures which are subject to overflow should be avoided. All lambs born in April or May should be drenched about August or September following, to be certain of ridding them of worms that may later cause their death.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is output from a tool I built called &lt;em&gt;Veterinary Ipsum&lt;/em&gt;. It&amp;rsquo;s something I&amp;rsquo;ve created a few times: a Lorem Ipsum generator specific to my company&amp;rsquo;s business domain.&lt;/p&gt;</description></item><item><title>Thinking of Bugs in Classes</title><link>https://jakeworth.com/posts/thinking-of-bugs-in-classes/</link><pubDate>Sun, 03 Sep 2023 00:00:00 +0000</pubDate><guid>https://jakeworth.com/posts/thinking-of-bugs-in-classes/</guid><description>&lt;p&gt;We spent the time writing tests, and yet, a bug survived. Should we just stop
writing tests? No, but we should maybe write better tests, and think about them differently.&lt;/p&gt;</description></item><item><title>Cold Water for Your Code Coverage</title><link>https://jakeworth.com/posts/cold-water-for-your-code-coverage/</link><pubDate>Tue, 28 Mar 2023 00:00:00 +0000</pubDate><guid>https://jakeworth.com/posts/cold-water-for-your-code-coverage/</guid><description>&lt;p&gt;Code coverage, the percentage of your code covered by automated tests, is a
metric associated with quality. In this post, I&amp;rsquo;d like to investigate this
association. And pour some cold water on it.&lt;/p&gt;</description></item><item><title>The Factory Pattern, Explained in Ruby</title><link>https://jakeworth.com/posts/why-use-factorybot/</link><pubDate>Mon, 17 Oct 2022 00:00:00 +0000</pubDate><guid>https://jakeworth.com/posts/why-use-factorybot/</guid><description>&lt;p&gt;In this post, I&amp;rsquo;ll explain what factories are and why you want them, using Ruby.&lt;/p&gt;</description></item><item><title>RSpec.describe vs. describe: Which Should I Use?</title><link>https://jakeworth.com/posts/rspec-describe-vs-describe/</link><pubDate>Sat, 02 Apr 2022 00:00:00 +0000</pubDate><guid>https://jakeworth.com/posts/rspec-describe-vs-describe/</guid><description>&lt;p&gt;Ruby&amp;rsquo;s RSpec &lt;code&gt;describe&lt;/code&gt; block has two common syntaxes. Which should you use?&lt;/p&gt;</description></item><item><title>On Disabling Tests</title><link>https://jakeworth.com/posts/on-disabling-tests/</link><pubDate>Tue, 22 Feb 2022 00:00:00 +0000</pubDate><guid>https://jakeworth.com/posts/on-disabling-tests/</guid><description>&lt;p&gt;Today I want to talk about a common technique: disabling failing tests to allow
a feature to ship. Maybe sometimes you gotta do it. But long-term I think it
causes more problems than it solves.&lt;/p&gt;</description></item><item><title>Want Better Automated Tests? Hard-Code Your Expectations</title><link>https://jakeworth.com/posts/hard-code-your-expectations/</link><pubDate>Tue, 25 Jan 2022 00:00:00 +0000</pubDate><guid>https://jakeworth.com/posts/hard-code-your-expectations/</guid><description>&lt;p&gt;Hard-coded test expectations have many benefits that I&amp;rsquo;ll explore in this post.&lt;/p&gt;</description></item><item><title>ExtractRSpecLet</title><link>https://jakeworth.com/tils/extractrspeclet/</link><pubDate>Wed, 21 Apr 2021 11:13:08 -0400</pubDate><guid>https://jakeworth.com/tils/extractrspeclet/</guid><description>&lt;p&gt;Today I got to see the &lt;code&gt;:ExtractRspecLet&lt;/code&gt; command from the &lt;a href="https://github.com/jgdavey/vim-weefactor"&gt;vim-weefactor&lt;/a&gt; plugin. It does what the names suggests, converting this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ruby" data-lang="ruby"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# spec/model/foobar_spec.rb&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;foo &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;FactoryGirl&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;create &lt;span style="color:#e6db74"&gt;:foobar&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ruby" data-lang="ruby"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# spec/model/foobar_spec.rb&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;let(&lt;span style="color:#e6db74"&gt;:foo&lt;/span&gt;) { &lt;span style="color:#66d9ef"&gt;FactoryGirl&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;create &lt;span style="color:#e6db74"&gt;:foobar&lt;/span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It also moved the new &lt;code&gt;let&lt;/code&gt; from inside my &lt;code&gt;it&lt;/code&gt; block to right underneath my &lt;code&gt;context&lt;/code&gt; block. Awesome!&lt;/p&gt;
&lt;p&gt;h/t Josh Davey and Dillon Hafer&lt;/p&gt;</description></item><item><title>A Short Introduction to Test-Driven-Development (TDD)</title><link>https://jakeworth.com/posts/intro-to-tdd/</link><pubDate>Wed, 11 Sep 2019 00:00:00 +0000</pubDate><guid>https://jakeworth.com/posts/intro-to-tdd/</guid><description>&lt;p&gt;I&amp;rsquo;ve practiced TDD (Test-Driven-Development) a lot and feel knowledgable about when it&amp;rsquo;s useful and when it isn&amp;rsquo;t. In this post,
I&amp;rsquo;d like to summarize what I&amp;rsquo;ve learned.&lt;/p&gt;</description></item><item><title>Learn to Test</title><link>https://jakeworth.com/posts/learn-to-test/</link><pubDate>Fri, 15 Jul 2016 00:00:00 +0000</pubDate><guid>https://jakeworth.com/posts/learn-to-test/</guid><description>&lt;p&gt;What is a skill one could learn to set themselves apart from other entry-level programmers? Testing.&lt;/p&gt;</description></item><item><title>Expect a Case-Insensitive Match</title><link>https://jakeworth.com/tils/expect-a-caseinsensitive-match/</link><pubDate>Tue, 05 Jan 2016 17:37:00 -0600</pubDate><guid>https://jakeworth.com/tils/expect-a-caseinsensitive-match/</guid><description>&lt;p&gt;We had a testing issue this week when a button&amp;rsquo;s text &lt;code&gt;save changes!&lt;/code&gt; was rendering as &lt;code&gt;SAVE CHANGES!&lt;/code&gt;, due to the CSS property &lt;code&gt;text-transform: uppercase&lt;/code&gt;. How do you test that?&lt;/p&gt;
&lt;p&gt;One technique is to use RSpec&amp;rsquo;s &lt;code&gt;match&lt;/code&gt; method, and include case insensitivity with &lt;code&gt;i&lt;/code&gt; (explored earlier &lt;a href="http://til.hashrocket.com/posts/4dc84ebcb8-caseinsensitive-substitution"&gt;here&lt;/a&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ruby" data-lang="ruby"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; button_text &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;foo&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;foo&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; expect(button_text)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;to match(&lt;span style="color:#e6db74"&gt;&amp;#34;FOO&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;RSpec&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;Expectations&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#e6db74"&gt;ExpectationNotMetError&lt;/span&gt;: expected &lt;span style="color:#e6db74"&gt;&amp;#34;foo&amp;#34;&lt;/span&gt; to match &lt;span style="color:#e6db74"&gt;&amp;#34;FOO&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# stuff&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; expect(button_text)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;to match(&lt;span style="color:#e6db74"&gt;/FOO/i&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We ultimately hard coded the expectation to &lt;code&gt;match(&amp;quot;FOO&amp;quot;)&lt;/code&gt;, because allowing &lt;code&gt;fOo&lt;/code&gt; and &lt;code&gt;FoO&lt;/code&gt; seemed too permissive. But it remains an option.&lt;/p&gt;</description></item><item><title>Testing Edit Forms</title><link>https://jakeworth.com/tils/testing-edit-forms/</link><pubDate>Tue, 17 Nov 2015 07:53:31 -0600</pubDate><guid>https://jakeworth.com/tils/testing-edit-forms/</guid><description>&lt;p&gt;Today I found a way to assert that an edit form&amp;rsquo;s inputs include a record&amp;rsquo;s saved data. I think it strikes a good balance between broad and narrow scope.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ruby" data-lang="ruby"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# spec/features/user_edits_kit_spec.rb&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;within &lt;span style="color:#e6db74"&gt;&amp;#39;form&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; expect(page)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;to have_selector(&lt;span style="color:#e6db74"&gt;&amp;#34;input[value=&amp;#39;Default copy.&amp;#39;]&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This asserts that some content is inside an input field in the form, rather than just anywhere on the page. You can narrow the scope as needed.&lt;/p&gt;</description></item></channel></rss>