<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chuck Blaine</title>
    <description>The latest articles on DEV Community by Chuck Blaine (@cblaine).</description>
    <link>https://dev.to/cblaine</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F254579%2F7f4ef697-4f27-4621-ad9a-bc32fbdd6e7d.png</url>
      <title>DEV Community: Chuck Blaine</title>
      <link>https://dev.to/cblaine</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cblaine"/>
    <language>en</language>
    <item>
      <title>How We Test Angular2+ (Part 2)</title>
      <dc:creator>Chuck Blaine</dc:creator>
      <pubDate>Sat, 11 Sep 2021 21:48:25 +0000</pubDate>
      <link>https://dev.to/cblaine/how-we-test-angular2-part-2-21b4</link>
      <guid>https://dev.to/cblaine/how-we-test-angular2-part-2-21b4</guid>
      <description>&lt;p&gt;Hey there. This is part two in a series of undefined length. See what I did there?&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://dev.to/nha/how-we-test-angular2-19al"&gt;part one&lt;/a&gt; I gave a little intro and explained that I'm trying to write these blogs with as much detail in each step (including the issues you will inevitably run into) as possible. I'll try to be consistent in format so you can learn the pattern and jump to what interests you easier as time goes on. If you want to play with the code you can find it &lt;a href="https://github.com/cblaine/angular-testing-demo"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Previously, we got the sample angular app that comes with the cli up and running and got our tests running. Now we'll add some kind of functionality to our app. I want to get as many bells and whistles going ASAP so we can grow the app uniformly instead of adding libraries and things along the way so we're going to install a bunch of stuff to start off. I'll explain details about each package as it becomes necessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Goal
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Add a module&lt;/li&gt;
&lt;li&gt;Install and configure an NgRx store&lt;/li&gt;
&lt;li&gt;Write some tests and simple functionality&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;First let's get NgRx installed by running the following command.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng add @ngrx/store@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I like using the CLI for stuff like this because other nerds have already done the work of updating module files and doing the npm install for us and I'm lazy so they did it specifically for me and who am I to deny their hard work? You can do all kinds of things by passing optional parameters so check out the &lt;a href="https://ngrx.io/guide/store/install#optional-ng-add-flags"&gt;docs&lt;/a&gt; sometime.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's start by running our tests. We'll try some TDD 🙂&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Process
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;First some housekeeping. Get rid of the sample template stuff.

&lt;ul&gt;
&lt;li&gt;Clear out the app.component.html file. When you do you should see your tests start to fail. Go ahead and clear out the tests for now too. You should be seeing &lt;code&gt;TOTAL: 0 SUCCESS&lt;/code&gt; now.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Now let's make something!
&lt;/h3&gt;

&lt;p&gt;I thought about this for a while and decided I'm going to build something for myself and I guess anybody else that wants it 🙂. I play D&amp;amp;D and am a lazy programmer with terrible handwriting so I want somewhere I can keep track of the events of campaigns. I want to track things like characters we meet, quests we go on or are available to explore, locations we visit, important notes about those locations, and probably tons of other stuff that I haven't thought of.  So let's get to it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Add a module
&lt;/h4&gt;

&lt;p&gt;The main "object" in D&amp;amp;D is the campaign itself so I'm thinking we add a module for the campaign and then we'll add submodules for all the pieces. I'm going to try and use the cli as much as possible because I don't usually and I want to learn it better. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We'll ask the cli to &lt;code&gt;g&lt;/code&gt;enerate us a &lt;code&gt;module&lt;/code&gt; called &lt;code&gt;Campaign&lt;/code&gt; (the cli will append "Module" onto the name for us). We can also have it do a few other things for us by passing some switches. We'll tell it that

&lt;ul&gt;
&lt;li&gt;the &lt;code&gt;--module App&lt;/code&gt; is where the Campaign module will be defined&lt;/li&gt;
&lt;li&gt;we want the &lt;code&gt;--route "campaigns"&lt;/code&gt; to map to the new module. &lt;/li&gt;
&lt;li&gt;we want &lt;code&gt;--routing&lt;/code&gt; to be setup for the new module as well so we can lazy load sub modules&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can read all about the cli options in the &lt;a href="https://angular.io/cli/generate#module"&gt;docs&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng g module Campaign --module App --route "campaigns" --routing true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you've followed along up to this point and start the app then you should see the "campaign works!" string in the browser... right?  That's what we want.&lt;/p&gt;

&lt;p&gt;Here's what actually happened for me... I see nothing.  Then I remembered that we deleted all the template stuff out of the app component so it's empty. Here's what I did next...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Added "App works!" to the app.component.html and then that showed up but the "campaign works!" string still wasn't showing.&lt;/li&gt;
&lt;li&gt;Remembered we have to add the &lt;code&gt;&amp;lt;router-outlet&amp;gt;&amp;lt;/router-outlet&amp;gt;&lt;/code&gt; to the app component template. But that still didn't do it...&lt;/li&gt;
&lt;li&gt;Looked at the browser and saw that the url was &lt;code&gt;http://localhost:4200/&lt;/code&gt; but I knew that I wanted the &lt;code&gt;/campaigns/&lt;/code&gt; route to map to my Campaign component so then I also knew I had a routing issue.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We have two routing modules right now, one at the App level and one at the Campaign level. Since we're just at the root of our app right now, let's look at the root routing module &lt;code&gt;app-routing.module.ts&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If we inspect the routes that the cli set up for us we can see that we indeed got the mapping we asked for but the issue is that we're not routed to that route by default.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Added an entry to the array telling the router that if the full route (i.e. all the stuff after the localhost part) in the browser is empty then send the request to the campaigns route. The "campaign works!" string started showing up after this last change.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;{ path: '', redirectTo: 'campaigns', pathMatch: 'full' }&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h4&gt;
  
  
  Add our first feature component
&lt;/h4&gt;

&lt;p&gt;I'm going to add some interfaces and some factory functions for building fake objects in our tests and then I'll make a new component for creating campaigns with the following command. You can check out the details of the files in the &lt;a href="https://github.com/cblaine/angular-testing-demo"&gt;repo&lt;/a&gt; if you're interested.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;g&lt;/code&gt;enerate a &lt;code&gt;c&lt;/code&gt;component called NewCampaign under the &lt;code&gt;m&lt;/code&gt;odule Campaign and set the &lt;code&gt;c&lt;/code&gt;hangeDetection policy to OnPush&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Note: the cli will add a prefix to component selectors by default.  You can customize this with the &lt;code&gt;--prefix&lt;/code&gt; switch and passing a string or you can use the &lt;code&gt;--selector&lt;/code&gt; switch to explicitly set the entire selector string. I'm removing the default &lt;code&gt;app-&lt;/code&gt; prefix.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ng g c NewCampaign -m Campaign -c OnPush --prefix ""&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let's add the &lt;code&gt;&amp;lt;new-campaign&amp;gt;&amp;lt;/new-campaign&amp;gt;&lt;/code&gt; element to the CampaignComponent template and now we should see our "new campaign works!" string.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  TDD time.
&lt;/h4&gt;

&lt;p&gt;We'll try to emulate the fail, refactor, pass pattern for TDD. We'll write a failing test and then refactor code until it passes and then just keep doing that over and over.&lt;/p&gt;

&lt;p&gt;When you create a component with the cli Angular will add a test file for you with the standard jasmine syntax. I'm going to use Spectator so this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ComponentFixture, TestBed } from '@angular/core/testing';

import { NewCampaignComponent } from './new-campaign.component';

describe('NewCampaignComponent', () =&amp;gt; {
  let component: NewCampaignComponent;
  let fixture: ComponentFixture&amp;lt;NewCampaignComponent&amp;gt;;

  beforeEach(async () =&amp;gt; {
    await TestBed.configureTestingModule({
      declarations: [ NewCampaignComponent ]
    })
    .compileComponents();
  });

  beforeEach(() =&amp;gt; {
    fixture = TestBed.createComponent(NewCampaignComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () =&amp;gt; {
    expect(component).toBeTruthy();
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;will become this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createComponentFactory, Spectator } from '@ngneat/spectator';
import { NewCampaignComponent } from './new-campaign.component';


describe('NewCampaignComponent', () =&amp;gt; {
  let spectator: Spectator&amp;lt;NewCampaignComponent&amp;gt;;
  const createComponent = createComponentFactory({
    component: NewCampaignComponent
  });

  beforeEach(async () =&amp;gt; {
    spectator = createComponent();
  });

  it('should create', () =&amp;gt; {
    expect(spectator.component).toBeTruthy();
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spectator just takes care of a lot of boilerplate code that gets repeated in practically every test.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can get some nice syntactic sugar and utilities for your tests by installing &lt;a href="https://www.npmjs.com/package/@ngneat/spectator"&gt;Spectator&lt;/a&gt; which is made by the fine folks at &lt;a href="https://github.com/ngneat"&gt;ngneat&lt;/a&gt;. Install it like so. Again, I'll explain things as we go and as we need.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i @ngneat/spectator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;I have mixed feelings about libraries like this because they can obscure what's going on under the sheets and then when things go wrong it can be even harder to figure out the problem. With that in mind, I still find the convenience that Spectator provides sufficient to accept the risk.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Let's write a test for our NewCampaign component.  I want a field for every property on my model so let's start there.  Here's my first test:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  it(`should have a firstName field`, () =&amp;gt; {
    const firstNameField = spectator.query('input.campaign-name');
    expect(firstNameField).toBeTruthy();
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding an &lt;code&gt;f&lt;/code&gt; to the front of the &lt;code&gt;describe&lt;/code&gt; in a spec file &lt;code&gt;f&lt;/code&gt;ocuses the test runner on that test. This will reduce the noise a bit as time goes on. What I see in my console is this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zNoUr8PS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6k01okcv2xwofrgw1463.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zNoUr8PS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6k01okcv2xwofrgw1463.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So we got the first step done. Failing test ✅. Now all we have to do is make it pass. As an aside, one of the reasons I like TDD is that it drives your design process from a consumer perspective. More on that later. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's add an input with a class called &lt;code&gt;campaign-name&lt;/code&gt;. Adding this to the template turns our test green.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;input type="text" class="campaign-name" [placeholder]="'Enter a Campaign Name'" /&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Refactor Code ✅&lt;br&gt;
Passing Test ✅&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We'll repeat this process for the other properties of the model by first writing a test that fails and then adding the code to make it pass. Try this with a couple more model properties for funsies. Then let's pause on this and switch gears for a moment.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Wiring up the NgRx store
&lt;/h4&gt;

&lt;p&gt;I mentioned bells and whistles earlier so let's get our store set up and some peripherals we use for our development process.&lt;sup id="fnref1"&gt;1&lt;/sup&gt; When we ran the &lt;code&gt;ng add&lt;/code&gt; command at the very beginning of this post the cli did some housekeeping for us like updating the app.module.ts to import the &lt;code&gt;StoreModule.forRoot()&lt;/code&gt;. We need to do a few similar things before we're ready to roll with the NgRx store. I'm not going to cover how Angular module factories and injectors work or how NgRx works but if you have questions just post them below and I'll do my best to help out.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you use NgRx you should consider using entity state. This is nice for managing state in NgRx. Again, post any questions below.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;ng add @ngrx/entity@latest&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Just setup enough of the store so that it loads. The minimum is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add &lt;code&gt;StoreModule.forRoot({})&lt;/code&gt; to the imports array of the App module&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;StoreModule.forFeature()&lt;/code&gt; to the imports array of the Campaign module

&lt;ul&gt;
&lt;li&gt;Create a campaign reducer and add it to the &lt;code&gt;forFeature()&lt;/code&gt; arguments list&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have the redux dev tools&lt;sup id="fnref2"&gt;2&lt;/sup&gt; setup in your browser you should see the store with your state there now kind of like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DBHte9W---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9yg55xqfe66ssys9ywa4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DBHte9W---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9yg55xqfe66ssys9ywa4.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Sausage
&lt;/h2&gt;

&lt;p&gt;We got a module created and a new component added inside that module.  We also got our NgRx store setup and have an action that we can dispatch from our component and a corresponding reducer function that will allow us to persist data to the store. And we even have some tests. 🙂&lt;/p&gt;

&lt;h2&gt;
  
  
  The Credits
&lt;/h2&gt;

&lt;p&gt;We've come a long way already! Much of the work we've done up to this point has been foundational stuff but in the next episodes we'll start having more fun by spending more time building helpful features and more testing all along the way. I'll try to dedicate attention to this blog more often so that there aren't such big gaps between posts but life is busy and it doesn't seem to be slowing down.&lt;/p&gt;

&lt;p&gt;As always, I welcome questions, discussions, and suggestions for the types of features you'd like to see implemented in the app.&lt;/p&gt;

&lt;p&gt;Thanks for spending some of your time with me. Be Well.&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;I'm showing how we do things at NHA in this project. It's arguable that NgRx is overkill for this project right now but there are other benefits besides scaling. Maybe we can have a post sometime where we could manage local subjects and observables instead of using NgRx store. ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn2"&gt;
&lt;p&gt;Pro Tip: If you're going to work with NgRx do yourself a favor and get the &lt;a href="https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd?hl=en"&gt;Redux Dev Tools&lt;/a&gt; extension for your browser. You won't regret it. Also have a look at the &lt;a href="https://ngrx.io/guide/store-devtools"&gt;docs&lt;/a&gt; because you have to make a change in your module file in order to use the tools. ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>angular</category>
      <category>testing</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How We Test Angular2+</title>
      <dc:creator>Chuck Blaine</dc:creator>
      <pubDate>Sun, 20 Jun 2021 16:10:02 +0000</pubDate>
      <link>https://dev.to/nha/how-we-test-angular2-19al</link>
      <guid>https://dev.to/nha/how-we-test-angular2-19al</guid>
      <description>&lt;p&gt;Hi, I'm Chuck. This will be my first attempt at trying to contribute back to the community in some way and I'm going to try and do it in the realm of testing. So bear with me 🙂.  I appreciate all feedback and constructive feedback is the most helpful.&lt;/p&gt;

&lt;p&gt;Throughout my career as a developer I have heard a lot of people agree that testing our code is something that we should all be doing. Conversely, I have not worked at many places that actually do it. Additionally, and surprisingly to me, rarely if ever do you see a tutorial show any kind of testing when they're trying to teach something unless they're specifically teaching testing.&lt;/p&gt;

&lt;p&gt;While I understand that the focus of the lesson may not be testing, I think that if we really want to see testing adopted more widely across our industry then we need to normalize it as part of the standard development process and show examples of it happening in practice. I think this will help to remove barriers that may be holding some people back. OK... rant over. Let's get into it and see how the sausage is made.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Goal
&lt;/h1&gt;

&lt;p&gt;The objective for this first post is to walk through the setup process so we can get to a point where we have a running test. It'll be trivial and useless but let's crawl before we walk.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Setup
&lt;/h1&gt;

&lt;p&gt;I'm starting from scratch. Nothing at all except an empty repository which you can find &lt;a href="https://github.com/cblaine/angular-testing-demo"&gt;here&lt;/a&gt;. I'm going to document all of my steps so you can see what I'm going through instead of a super curated end product that says, "Here, just [insert steps that should really not be prefaced with the word "just"] and presto you're testing! GLHF!". SPOILER: The real world doesn't work like that. Instead it's filled with all kinds of WTF moments and banging your head against Google search results. This has been my experience. Your results may vary.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Process
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;OK. First things first. Let's get an angular app setup. To do that we leverage the Angular CLI and run a command that looks something like:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng new angular-testing-demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the very first thing I see is an error saying &lt;code&gt;'ng'&lt;/code&gt; is not a recognized command. That's because I don't have the cli installed in my global npm environment. So it's not a lie. We fix that with this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -g @angular/cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when we run the &lt;code&gt;ng new&lt;/code&gt; command it'll be recognized. Cool, one StackOverflow search eliminated. You're welcome.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's try and run the tests
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M2qJa6B2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/naiqhwauef9d3bus1wyy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M2qJa6B2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/naiqhwauef9d3bus1wyy.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
Neat. Tests are running. Pretty quick and easy actually.&lt;/p&gt;

&lt;p&gt;I say that because I've never actually setup tests from scratch before this. Again, the real world rarely looks like what you see online (crazy right?).&lt;/p&gt;

&lt;h1&gt;
  
  
  The Sausage
&lt;/h1&gt;

&lt;p&gt;We're set up from scratch in very little time and have running tests. That's all I wanted to accomplish for the first post so we'll stop here. In the following posts we'll start adding more and more complexity to the app and I'll try to incorporate all the fancy bells and whistles that we're using in our code because that's the type of complexity you'll encounter in the real world.&lt;/p&gt;

&lt;h1&gt;
  
  
  Bonus Scene Right Before The Credits
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;The browser UI is nice to look at but we really don't need it right now so let's turn it off. By default, the CLI will set you up using Karma as a test runner and Jasmine as your testing framework. There is a file that gets generated called &lt;code&gt;karma.conf.js&lt;/code&gt; where you can tweak how tests will run and near the end of that file you'll see a key for &lt;code&gt;browsers&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// browsers: ['Chrome'], // This is what you'll see there already
browsers: ['ChromeHeadless'], // This is what you want it to be
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when we run our tests Karma won't try to open an actual browser but will instead use a Headless browser which runs in memory.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qM4eQ0tF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wuzui9iq1xcyka5v5n6v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qM4eQ0tF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wuzui9iq1xcyka5v5n6v.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
One more StackOverflow search eliminated.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Credits
&lt;/h1&gt;

&lt;p&gt;When we started our testing initiative at NHA, we already had a pretty good sized application running with many modules and submodules, custom SCSS, custom Javascript extension functions, NgRx state management, the list goes on. So when we went to get things setup it was not at all as easy as what I just showed you.&lt;/p&gt;

&lt;p&gt;So I'm curious to know if anybody else is stuck in a similar spot and has an existing codebase in place where they're trying to get started testing and the tutorials don't explain enough to help.&lt;/p&gt;

&lt;p&gt;I welcome questions, discussions, and suggestions for the types of features you'd like to see implemented in the app.&lt;/p&gt;

&lt;p&gt;Thanks for spending some of your time with me. Be Well.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>testing</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
