<?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: Andre Willomitzer</title>
    <description>The latest articles on DEV Community by Andre Willomitzer (@andrewillomitzer).</description>
    <link>https://dev.to/andrewillomitzer</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%2F701784%2Fca1d0e74-a131-4591-a039-00a249f9cbfe.jpeg</url>
      <title>DEV Community: Andre Willomitzer</title>
      <link>https://dev.to/andrewillomitzer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andrewillomitzer"/>
    <language>en</language>
    <item>
      <title>My Final Week Of Open Source at Seneca</title>
      <dc:creator>Andre Willomitzer</dc:creator>
      <pubDate>Fri, 10 Dec 2021 21:42:33 +0000</pubDate>
      <link>https://dev.to/andrewillomitzer/my-final-week-of-open-source-at-seneca-em7</link>
      <guid>https://dev.to/andrewillomitzer/my-final-week-of-open-source-at-seneca-em7</guid>
      <description>&lt;h2&gt;
  
  
  What the class was about
&lt;/h2&gt;

&lt;p&gt;For those who haven't seen some of my previous blogs about the OSD600 open source class at Seneca College here is some background... My name is Andre Willomitzer and I am a Seneca College student taking this class. I am trying to specialize in JavaScript/TypeScript/NodeJS and web development.&lt;/p&gt;

&lt;p&gt;OSD600 is about contributing to open source projects on GitHub, collaborating with professional developers/maintainers and also our fellow students. The goal of this is to learn how to leverage the community and learn from each other to build better software and learn best practices.&lt;/p&gt;

&lt;p&gt;Throughout the class we have built our own static site generators and also contributed to a variety of projects "out in the wild".&lt;/p&gt;

&lt;h2&gt;
  
  
  The Final Release 0.4
&lt;/h2&gt;

&lt;p&gt;For the final release we are supposed to once again pick an open source repository. I have chosen &lt;a href="https://github.com/lbdremy/solr-node-client"&gt;solr-node-client&lt;/a&gt; which allows you to run solr on NodeJS using a Docker container. What I was hoping to fix in this repository that one of the maintainers &lt;a href="https://github.com/kibertoad"&gt;Igor Savin&lt;/a&gt; told me about is that the tests were not browser compatible (he knew about that). &lt;/p&gt;

&lt;p&gt;The repository did not yet have browser tests set up, but he knew that the Undici library was not compatible with browsers.&lt;/p&gt;

&lt;h2&gt;
  
  
  First Steps
&lt;/h2&gt;

&lt;p&gt;To run browser tests, I decided to use &lt;a href="http://karma-runner.github.io/6.3/index.html"&gt;Karma&lt;/a&gt;. It is something I previously set up in another TypeScript project, and since the existing tests use &lt;code&gt;describe()&lt;/code&gt; and &lt;code&gt;it()&lt;/code&gt; functions it seemed like the best choice again.&lt;/p&gt;

&lt;p&gt;First I installed the dependencies such as jasmine-core, karma, karma-chrome-launcher, karma-jasmine, and karma-typescript. These allow the Jasmine tests to run and also compile typescript using pre-processing. I also added a script to the package.json file to run the karma --start command.&lt;/p&gt;

&lt;p&gt;Next I had to create the config file (note the compiling to JS from TS):&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FUSdCtIZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cfz4sgqbc6jw5koztmqq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FUSdCtIZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cfz4sgqbc6jw5koztmqq.png" alt="Image description" width="880" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running The Tests
&lt;/h2&gt;

&lt;p&gt;Well running the tests went about as well as expected (3-4 errors and very cryptic). One of the errors was &lt;code&gt;esModuleInterop&lt;/code&gt; which means one of the modules was using an older import statement no longer compatible. I went and fixed several imports such as:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hoieAsfM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yadgdwga19svc3hcqtwd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hoieAsfM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yadgdwga19svc3hcqtwd.png" alt="Image description" width="880" height="66"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that it was just 1 error left... And that is where I got stopped in my tracks. The error was once again very cryptic. It said one of the imports was not a function even though I used &lt;code&gt;require()&lt;/code&gt; in the exact same way as my other imports. &lt;/p&gt;

&lt;p&gt;Due to this, I was unable to even run the existing tests using Karma to try and fix the Undici errors. &lt;/p&gt;

&lt;p&gt;Unfortunately, I was unable to solve the issue of browser incompatibility. I believe this was in part to choosing a repository which I had no prior experience with... on top of it being a really complex issue but I was hoping to push myself. However, I am satisfied because I learned a lot still during this project.&lt;/p&gt;

&lt;h2&gt;
  
  
  My takeaways
&lt;/h2&gt;

&lt;p&gt;Working on this project has exposed me to learning how to install Docker on Windows 10 which I will likely need to do at some point in my future as a developer. Furthermore, I learned how to configure Karma for a project that runs tests using a container like Docker which required some extra set up. I was also able to learn about debugging cryptic errors when setting up configurations for things like Karma, and Docker which required a lot of determination.&lt;/p&gt;

&lt;p&gt;In addition, due to my own struggles and taking a long time to set up Docker Desktop I wrote README documentation in the repository about how to do it for future developers who want to contribute. I found a lot of my time was spent initially getting the Docker container running rather than actually trying to fix the issue at hand. So if other developers can avoid that it's good. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion... It's about the friends we made along the way.
&lt;/h2&gt;

&lt;p&gt;I have learned an immense amount during OSD600 at Seneca. I got the chance to work on some amazing projects like &lt;a href="https://github.com/jasmine/jasmine"&gt;jasmine&lt;/a&gt;, &lt;a href=""&gt;toad-scheduler&lt;/a&gt; where I got to fix a setInterval() bug, and &lt;a href="https://github.com/lbdremy/solr-node-client"&gt;solr-node-client&lt;/a&gt;. These projects have exposed me to professional development workflows and how development is done "in the real world" with tools like linting, automated testing, continuous integration. All things I was previously unaware of.&lt;/p&gt;

&lt;p&gt;Although I am a little sad I was unable to fix the issue I set out to in this Release 0.4, I feel that it was valuable and I plan to continue contributing to Open Source in my future whenever possible. I met some amazing people who have been extremely helpful and kind in letting a new developer such as myself work on their repositories.&lt;/p&gt;

&lt;p&gt;I plan to take OSD700 next winter if I can, after I complete my internship. In the meantime I would like to contribute to more open source projects even if it's small fixes. It's a fun way to learn and meet interesting people.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Release 0.4 Progression</title>
      <dc:creator>Andre Willomitzer</dc:creator>
      <pubDate>Thu, 09 Dec 2021 18:30:09 +0000</pubDate>
      <link>https://dev.to/andrewillomitzer/release-04-progression-43ji</link>
      <guid>https://dev.to/andrewillomitzer/release-04-progression-43ji</guid>
      <description>&lt;h3&gt;
  
  
  The Task At Hand
&lt;/h3&gt;

&lt;p&gt;This past week I have been working on &lt;a href="https://github.com/lbdremy/solr-node-client"&gt;solr-node-client&lt;/a&gt; repository, and attempting to adjust their test cases to be browser compatible with the help of the maintainers. &lt;/p&gt;

&lt;p&gt;In order to do this, I have had to learn a lot about setting up Docker containers locally. This has been made even more of a challenge by the fact that I am on Windows 10 Home, which is missing some nice little features like enabling Hyper-V.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I have accomplished so far
&lt;/h3&gt;

&lt;p&gt;So far, I have managed to install Docker Desktop for Windows 10 Home. This involved workarounds using a &lt;a href="https://www.itechtics.com/enable-hyper-v-windows-10-home/"&gt;batch file&lt;/a&gt; (.bat) and installing WSL/WSL2 and the Linux kernel update manually.&lt;/p&gt;

&lt;p&gt;First, I had to install developer dependencies for &lt;code&gt;jasmine-core&lt;/code&gt;, &lt;code&gt;karma&lt;/code&gt;, &lt;code&gt;karma-chrome-launcher&lt;/code&gt;, and &lt;code&gt;karma-jasmine&lt;/code&gt;. Also in the package.json file, I added a script to run the karma tests: &lt;code&gt;"karma-tests": "karma start --single-run --browsers ChromeHeadless karma.conf.js",&lt;/code&gt;.&lt;br&gt;
In the repository itself I have set up the &lt;code&gt;karma.config.js&lt;/code&gt; file  to use Headless Chrome. &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sgrBra2a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ls2nsd4bu0fhnblstffy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sgrBra2a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ls2nsd4bu0fhnblstffy.png" alt="Image description" width="880" height="275"&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Running the tests
&lt;/h3&gt;

&lt;p&gt;When I initially ran the tests, I had to start Docker by running &lt;code&gt;npm run solr:current:start&lt;/code&gt; to start the Docker container. And then to execute the tests, I ran my karma-test command with it pointing to the existing &lt;code&gt;test&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;Surprisingly, it didn't work. Because the project uses Typescript rather than JavaScript which Karma is made for, I had to create an exception for &lt;code&gt;.ts&lt;/code&gt; files in the config file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;files: [
      {
        pattern: 'test/**/*.ts',
        type: 'js'  // to silence the warning. Means load with &amp;lt;script&amp;gt; tag
      },
    ],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make sure it wasn't my Karma setup, I created a basic Karma test of adding 1+1 and making sure it equals 2. The test passed so I moved on to trying their already created tests.&lt;br&gt;
After running the tests with no Karma warnings, I started to get other errors which were 100% expected because that's why I made the issue branch to try and fix the browser incompatibilities. &lt;/p&gt;

&lt;p&gt;One error was about &lt;code&gt;esModuleInterop&lt;/code&gt; which I assumed was to do with some parts of the code using old import statements (even some packages) and some using &lt;code&gt;require()&lt;/code&gt;. In order to fix these I went into the &lt;code&gt;types.ts&lt;/code&gt; file and changed the import statement from &lt;code&gt;import Dispatcher from 'undici/types/dispatcher';&lt;/code&gt; to &lt;code&gt;import Dispatcher = require('undici/types/dispatcher');&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Upon changing that statement, I ran the tests again and had a strange error about "figc" one of the imports not being a function. From here, I decided it would be best to ask the maintainer what to do about this issue because changing the imports did not seem to fix it like it did the other issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  In the meantime and moving forward...
&lt;/h3&gt;

&lt;p&gt;Since I got a little stuck and Docker Desktop took so many tries, attempts, sweaty armpits to set up I asked the maintainers if I could add some documentation to the README about setting it up so that future developers can have an easier time getting going.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xjpR2AF7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5larpjtzfzabhfz8e29i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xjpR2AF7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5larpjtzfzabhfz8e29i.png" alt="Image description" width="880" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all for now!!!&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>javascript</category>
    </item>
    <item>
      <title>OSD600 Final Release Planning</title>
      <dc:creator>Andre Willomitzer</dc:creator>
      <pubDate>Tue, 30 Nov 2021 02:17:45 +0000</pubDate>
      <link>https://dev.to/andrewillomitzer/osd600-final-release-planning-55g4</link>
      <guid>https://dev.to/andrewillomitzer/osd600-final-release-planning-55g4</guid>
      <description>&lt;h4&gt;
  
  
  Release 0.4
&lt;/h4&gt;

&lt;p&gt;For this final assignment, we are tasked with contributing to another repository as we have done in the past. I am hoping to improve my Karma test skills even further by developing some tests that run in a Docker container. This is done in an application I intend to help add Karma to called &lt;a href="https://github.com/lbdremy/solr-node-client"&gt;solr-node-client&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The reason this must be done is the maintainers have let me know that the tests should fail in Karma because the application uses something known as &lt;code&gt;undici&lt;/code&gt; under the hood which is not supported in browsers.&lt;/p&gt;

&lt;h4&gt;
  
  
  My Plan
&lt;/h4&gt;

&lt;p&gt;My initial part will simply be writing the Karma config file and adding the existing tests to the Karma test commands. However, I am hoping to have enough time and skill to also find a solution with the help of the maintainers and to have a workaround in place for browser compatibility. Perhaps I will be able to write a few tests as well in order to get more experience with writing Jest and Karma tests.&lt;/p&gt;

&lt;h4&gt;
  
  
  What I hope to learn
&lt;/h4&gt;

&lt;p&gt;I am hoping to learn again from experienced developers like &lt;a href="https://github.com/kibertoad/toad-scheduler"&gt;Igor Savin&lt;/a&gt; and the folks at solr-node-client. Through this I will learn about browser testing and hope to write some tests of my own for the project (whatever they happen to want tested). Furthermore I think this will be a good overall learning experience to understand asynchronous programming because the API uses promises which I have less experience with than synchronous styles.&lt;/p&gt;

&lt;p&gt;I am excited and let's see how the next couple weeks go!&lt;/p&gt;

&lt;p&gt;Andre :)&lt;/p&gt;

</description>
      <category>opensource</category>
    </item>
    <item>
      <title>Publishing my first npm package</title>
      <dc:creator>Andre Willomitzer</dc:creator>
      <pubDate>Fri, 26 Nov 2021 19:36:11 +0000</pubDate>
      <link>https://dev.to/andrewillomitzer/publishing-my-first-npm-package-38ad</link>
      <guid>https://dev.to/andrewillomitzer/publishing-my-first-npm-package-38ad</guid>
      <description>&lt;h3&gt;
  
  
  The Project
&lt;/h3&gt;

&lt;p&gt;Eleven weeks ago when I started in Open Source Development 600 at Seneca I never thought I would get to the point of actually releasing something into the wild. Over the term we have been working on our individual static site generators. The purpose of these tools is to take a text file or Markdown file and parse it into a valid HTML document. &lt;/p&gt;

&lt;p&gt;It can include a variety of features depending on the student, but some of the options for my own &lt;a href="https://github.com/AndreWillomitzer/textToHTML_V2"&gt;textToHTML&lt;/a&gt; include stylesheets, using a config file instead of the command line, and having an output option to specify a folder to put the HTML documents into.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Journey
&lt;/h3&gt;

&lt;p&gt;Throughout the weeks, we have been contributing to Open Source projects on GitHub and making pull requests. Included in this is the idea of contributing to each other's SSG's. Collaborating with classmates has truly opened my eyes about new ways of doing things and best practices of development. All of my classmates such as &lt;a href="https://github.com/Kevan-Y"&gt;Kevan Yang&lt;/a&gt; have been instrumental in getting the tool ready for &lt;code&gt;npm&lt;/code&gt; deployment. &lt;/p&gt;

&lt;p&gt;We added linting, style guides, testing, continuous integration, among many other things throughout the semester. Each time, finding a better approach and refactoring. &lt;/p&gt;

&lt;h3&gt;
  
  
  How does npm deploying work?
&lt;/h3&gt;

&lt;p&gt;First of all, you will need to go to the &lt;a href="https://www.npmjs.com/"&gt;npm website&lt;/a&gt; and create an account. This is where your packages will be stored. Then, make sure you have npm installed on your computer. You can check using &lt;code&gt;npm -v&lt;/code&gt; in the terminal. &lt;/p&gt;

&lt;p&gt;Next you will need to run &lt;code&gt;npm login&lt;/code&gt; command and enter your credentials for the account you created. From the root directory of your project, run &lt;code&gt;npm publish&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt; you may get an error about a package with the same name existing. You may either create a &lt;a href="https://docs.npmjs.com/creating-and-publishing-scoped-public-packages"&gt;scoped package&lt;/a&gt; or change the name to something else. The name is found in the &lt;code&gt;package.json&lt;/code&gt; file of your application.&lt;/p&gt;

&lt;p&gt;That's it!!! Your package should show up on your npm account. However, if you want to tell people how to use your application you should create a &lt;code&gt;README.md&lt;/code&gt; with usage instructions, and then run &lt;code&gt;npm version patch&lt;/code&gt; and &lt;code&gt;npm publish&lt;/code&gt; again to release a new version. In order to do this your &lt;strong&gt;Git commit history must be clean&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to try my tool (if you want)
&lt;/h3&gt;

&lt;p&gt;As mentioned, I published a package as part of the course and the way to install it is via terminal. My tool is called &lt;a href="https://github.com/AndreWillomitzer/textToHTML_V2"&gt;textToHTML&lt;/a&gt;. You may type &lt;code&gt;npx texttohtmlv2&lt;/code&gt; in your command line. It will prompt you to install the package (say yes). Then, to see if it's working you can try the &lt;strong&gt;help&lt;/strong&gt; command by typing &lt;code&gt;npx texttohtmlv2 -h&lt;/code&gt; in the terminal. It should display a list of other things to try out.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final thoughts (for the final lab)
&lt;/h3&gt;

&lt;p&gt;This has been such an amazing journey in my 5th semester at Seneca. I have had the opportunity to contribute to things I never dreamed of having a hand in working on like the &lt;a href="https://github.com/jasmine/jasmine"&gt;jasmine testing framework&lt;/a&gt;, and also learned how to persevere when things aren't going right and to keep trying different approaches. I have also learned things that will serve me in my career such as Continuous Integration, end-to-end testing, Linting. &lt;/p&gt;

&lt;p&gt;Last, and certainly not least I learned about using Git. At first it was terrifying because all of the commands were foreign. Throughout the term we have been forced to adopt Git and learn to use commits, branches, merges, and pull requests to organize our work which has been an amazing learning experience.&lt;/p&gt;

&lt;p&gt;I know this article wasn't all about publishing, but I hope my experience inspires someone else to build a project even if it starts small.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

&lt;p&gt;Andre Willomitzer&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>webdev</category>
      <category>npm</category>
    </item>
    <item>
      <title>GitHub continuous integration basics (my experience).</title>
      <dc:creator>Andre Willomitzer</dc:creator>
      <pubDate>Fri, 19 Nov 2021 20:46:21 +0000</pubDate>
      <link>https://dev.to/andrewillomitzer/github-continuous-integration-basics-my-experience-2582</link>
      <guid>https://dev.to/andrewillomitzer/github-continuous-integration-basics-my-experience-2582</guid>
      <description>&lt;h3&gt;
  
  
  Looking back...
&lt;/h3&gt;

&lt;p&gt;Last week in class we added automated testing to our Static Site Generators (mine is called &lt;a href="https://github.com/AndreWillomitzer/textToHTML_V2"&gt;textToHTML&lt;/a&gt;). This included some tests for Jest which make sure the core functionality of our programs work as expected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Continuous Integration?
&lt;/h3&gt;

&lt;p&gt;After writing our tests, if you run &lt;code&gt;npm run test&lt;/code&gt; from the command line it will run the tests. But... what if someone who is contributing to your repository &lt;strong&gt;forgets&lt;/strong&gt; to run the tests before committing? &lt;/p&gt;

&lt;p&gt;Introducing continuous integration (I'm using the &lt;a href="https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python"&gt;GitHub version&lt;/a&gt;). &lt;/p&gt;

&lt;p&gt;This allows you to set up a &lt;code&gt;.github&lt;/code&gt; folder containing a &lt;code&gt;.yml&lt;/code&gt; file to configure your tests to run automatically on any push or pull request to your repository. The above linked article shows step by step how to set up the configuration folder and file for either Node.js or Python.&lt;/p&gt;

&lt;p&gt;Once the changes are made, commit them to your repository so GitHub has the &lt;code&gt;.github&lt;/code&gt; folder and &lt;code&gt;.yml&lt;/code&gt; file(s).&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing if it works
&lt;/h3&gt;

&lt;p&gt;If you want to test whether the continuous integration is working, create a branch from your main branch using &lt;code&gt;git checkout -b new-branch-name&lt;/code&gt;. Make some small change such as a spelling change to your &lt;code&gt;README.md&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Commit these changes to the branch, and then navigate to the GitHub website. Under your repository, you should see an option to "compare and pull request" the new branch with your main branch. &lt;/p&gt;

&lt;p&gt;If the continuous integration is set up properly, when you create the Pull Request it will run the checks you have outlined in your &lt;code&gt;.yml&lt;/code&gt; configuration files. In my case it runs &lt;code&gt;npm run test&lt;/code&gt; which executes my Jest test suites. You can also configure it to run &lt;strong&gt;linting&lt;/strong&gt; and &lt;strong&gt;prettier formatting&lt;/strong&gt; by using the corresponding scripts from &lt;code&gt;package.json&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zVGzijYx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/htl58ps7j6s7mbbuhgph.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zVGzijYx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/htl58ps7j6s7mbbuhgph.png" alt="Image description" width="880" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Ask A Friend
&lt;/h3&gt;

&lt;p&gt;After making a pull request to my own repository to check if the CI worked, my friend Kevan Yang and I added more tests to each other's repositories to create a pull request and test it that way.&lt;/p&gt;

&lt;p&gt;For my pull request to his project &lt;a href="https://github.com/Kevan-Y/text-ssg"&gt;text-to-ssg&lt;/a&gt; I tested one of his functions called &lt;code&gt;getAllFiles()&lt;/code&gt;. I wrote an &lt;code&gt;expect()&lt;/code&gt; function expecting the files function to throw if it does not find the file (it's not the function itself throwing, but the &lt;code&gt;fs.readfile&lt;/code&gt; function throwing).&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZdGuej-f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vqffxnrb3l9yxvq5z7ko.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZdGuej-f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vqffxnrb3l9yxvq5z7ko.png" alt="Image description" width="880" height="83"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Moving Forward
&lt;/h3&gt;

&lt;p&gt;In the future I plan to use continuous integration in my projects, and it was nice to have an understanding of how to set it up. It makes collaborating much easier because it stops unintentional bugs and code breaking changes by running the tests. Furthermore, it can be used for linting and styling which is useful because developers contributing to your project may not have the same style as you, and so the CI checks will report any differences.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Markdown file auditing: what I learned.</title>
      <dc:creator>Andre Willomitzer</dc:creator>
      <pubDate>Tue, 16 Nov 2021 17:18:52 +0000</pubDate>
      <link>https://dev.to/andrewillomitzer/markdown-file-auditing-what-i-learned-4a14</link>
      <guid>https://dev.to/andrewillomitzer/markdown-file-auditing-what-i-learned-4a14</guid>
      <description>&lt;h4&gt;
  
  
  C Programming At Seneca
&lt;/h4&gt;

&lt;p&gt;For the longest time, the C Programming class notes at Seneca were hosted on a &lt;a href="https://ict.senecacollege.ca/~ipc144/pages/content/index.html"&gt;website&lt;/a&gt;. However, given the development in web technologies and frameworks since their creation the professors and heads at Seneca have decided to reformat the notes into Markdown using &lt;a href="https://docusaurus.io/"&gt;Docusaurus&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Because this a huge undertaking, and we're all learning software development which includes documentation writing, the job of auditing the new Markdown files has come to us students.&lt;/p&gt;

&lt;h4&gt;
  
  
  What are we looking for?
&lt;/h4&gt;

&lt;p&gt;Generally the automatic conversion tool did a good job of taking the website notes and creating Markdown files. The files were added to Docusaurus and include dark mode. However, some things it missed or converted to non-standard ways of writing Markdown.&lt;/p&gt;

&lt;p&gt;For example, in the file I audited called &lt;a href="https://github.com/Seneca-ICTOER/IPC144/issues/26"&gt;functions.md&lt;/a&gt; the images were loaded properly using Docusaurus. &lt;strong&gt;But&lt;/strong&gt; because the original website did not have dark mode capability, the images backgrounds were not adjusted. This lead to issues like black arrows on a black background:&lt;/p&gt;

&lt;h6&gt;
  
  
  Before
&lt;/h6&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--trKFERIH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3a0pi6e7kcosb1o33jwg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--trKFERIH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3a0pi6e7kcosb1o33jwg.png" alt="Image description" width="880" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How I fixed it was using a &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; element around the images on the page with the class name &lt;code&gt;mdImg&lt;/code&gt;. Inside the global CSS file I added a selector of &lt;code&gt;.mdImg &amp;gt; p &amp;gt; img&lt;/code&gt; and changed the background color to white &lt;code&gt;background-color: #ffffff;&lt;/code&gt;. I used a &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; because they are inline as opposed to &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; which is block-level and may mess with responsiveness accidentally.&lt;/p&gt;

&lt;h6&gt;
  
  
  After
&lt;/h6&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DdSkZpX4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdf0w3fvx8d5kqa720ah.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DdSkZpX4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdf0w3fvx8d5kqa720ah.png" alt="Image description" width="880" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  React specific changes
&lt;/h4&gt;

&lt;p&gt;Since Docusaurus is built using React, and the original website was made using HTML/CSS. As such, when the HTML elements were rendered they used &lt;code&gt;class&lt;/code&gt; and &lt;code&gt;colspan&lt;/code&gt;. React uses &lt;code&gt;className&lt;/code&gt; and &lt;code&gt;colSpan&lt;/code&gt;. It didn't cause a direct error, but my friend &lt;a href="https://github.com/Kevan-Y"&gt;Kevan Yang&lt;/a&gt; pointed out it had many console errors so I changed all the classes. Furthermore, it didn't cause an error again but the &lt;code&gt;&amp;lt;tr&amp;gt;&lt;/code&gt; elements needed a matching &lt;code&gt;&amp;lt;thead&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;tbody&amp;gt;&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--spWH7yMW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yipcfsagu5ixnmkfy03f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--spWH7yMW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yipcfsagu5ixnmkfy03f.png" alt="Image description" width="880" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may also notice that I removed spaces before &lt;code&gt;&amp;lt;tr&amp;gt;&lt;/code&gt; because that's another issue in React rules that &lt;code&gt;&amp;lt;tr&amp;gt;&lt;/code&gt; can't have blank spaces before or between it. &lt;/p&gt;

&lt;h4&gt;
  
  
  Other small fixes
&lt;/h4&gt;

&lt;p&gt;Some smaller fixes included fixing the mispelling "parameter", adding alt tags to images, and adding Markdown admonitions for notes instead of blockquotes.&lt;/p&gt;

&lt;p&gt;I also removed inline CSS that was causing table backgrounds to be yellow even in dark mode:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2CxX26CY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ccmhk25fojk6fxd5anlo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2CxX26CY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ccmhk25fojk6fxd5anlo.png" alt="Image description" width="880" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  What I learned
&lt;/h4&gt;

&lt;p&gt;Auditing the file taught me a lot about attention to detail, in large part due to my friends code reviewing the pull request. I caught a lot of the issues myself at first, but things like the console error and the image in dark mode being incompatible I learned a lot about researching how to fix issues I haven't encountered before.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>markdown</category>
    </item>
    <item>
      <title>Code Reviews: Problems (but also solutions).</title>
      <dc:creator>Andre Willomitzer</dc:creator>
      <pubDate>Mon, 15 Nov 2021 22:21:25 +0000</pubDate>
      <link>https://dev.to/andrewillomitzer/code-reviews-problems-but-also-solutions-33ki</link>
      <guid>https://dev.to/andrewillomitzer/code-reviews-problems-but-also-solutions-33ki</guid>
      <description>&lt;h2&gt;
  
  
  What we're doing
&lt;/h2&gt;

&lt;p&gt;This assignment for our Open Source class has us doing some work with Markdown, HTML, and CSS to transfer the C Programming notes from Seneca College from a website, to a Docusaurus website using Markdown/HTML. Because the initial conversion was done doing an automatic tool, we are tasked with auditing and making sure the notes match the website. Images loading properly, looking good in dark mode, different screen sizes, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Reviews
&lt;/h3&gt;

&lt;p&gt;Part of the process of 50+ students working on a project is having a lot of reviewing to do so nothing breaks. The professor can't possibly do all of that and we're going to need to review in our developer journey, so it's time to learn!&lt;/p&gt;

&lt;p&gt;For this review I did a PR review for my friend &lt;a href="https://github.com/Kevan-Y"&gt;Kevan Yang&lt;/a&gt; who was &lt;a href="https://github.com/Seneca-ICTOER/IPC144/pull/22"&gt;adding PWA support&lt;/a&gt; to the application. Overall, there was not much to say about the code and Kevan did a great job. One small thing I noticed which is nitpicking is in the &lt;code&gt;manifest.json&lt;/code&gt; file the "name" and "description" for what the website does were different and needed to be the same: "IPC144 - Course Notes".&lt;/p&gt;

&lt;p&gt;Furthermore an issue with the PWA approach was the application launch icon being blurry. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OmJesJE4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u4urroj7nnw5kcsr54u8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OmJesJE4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u4urroj7nnw5kcsr54u8.png" alt="Image description" width="346" height="216"&gt;&lt;/a&gt;&lt;br&gt;
We tried to resolve this, and my suggestion was to attempt to resize the image and up the resolution using Adobe tools. The article I recommended to Kevan is &lt;a href="https://www.adobe.com/ca/creativecloud/photography/discover/increase-resolution.html"&gt;here&lt;/a&gt; which provides tools to use to try and change the image.&lt;/p&gt;

&lt;p&gt;Although it seemed like a good idea it didn't work, and a separate issue ended up being filed because Kevan had done a lot on the issue already. Fixing the image would have been too much in addition to that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Review 2
&lt;/h3&gt;

&lt;p&gt;For my second review, I decided to review one of my fellow students doing an audit/review of a Markdown file, &lt;a href="https://github.com/Seneca-ICTOER/IPC144/issues/44"&gt;information.md&lt;/a&gt;. The tool used to transfer the notes from a web page to Markdown files may have missed some syntax or images in the process.&lt;/p&gt;

&lt;p&gt;By the time I reviewed, &lt;a href="https://github.com/Yoda-Canada"&gt;Yoda-Canada (Tengzhen)&lt;/a&gt; had already made several fixes to the page&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fixed images in to be readable in dark mode&lt;/li&gt;
&lt;li&gt;Added alt text for diagram images.&lt;/li&gt;
&lt;li&gt;Replacing blockquotes with Markdown style admonitions like &lt;strong&gt;note&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  My suggestions
&lt;/h3&gt;

&lt;p&gt;The issues themselves were super well spotted and Tengzhen did a great job taking notice when reviewing the page. Some things I noticed because I also ran into them on my own auditing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To fix the dark mode image issue, I suggested wrapping them in a &lt;span&gt; tag and adding class "mdImg" to it. Then, using this, we can apply global CSS and have the background of the image white. On normal screens this does nothing but on dark mode it stops this from happening: 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6mTnW1fg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/50fpky3tasp8mktbfo3s.png" alt="Image description" width="703" height="282"&gt;
Instead, the image is white background and the arrows stay black.&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;I suggested removing the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; tags and sticking with the original Markdown images. The issue with using &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; is that block-style elements may mess with CSS and responsiveness by accident. &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; on the other hand is inline-styled.&lt;/li&gt;
&lt;li&gt;For regular text, I don't believe it is necessary to wrap them in &lt;p&gt; tags because we're using a Markdown file and so regular text that isn't preceded by a symbol like &lt;code&gt;###&lt;/code&gt; is treated like normal text. I suggested Tengzhen remove them.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Propose a solution
&lt;/h3&gt;

&lt;p&gt;What I learned from doing code reviews, is that it's really appreciated when you don't just point out the problem. Point out some reasons you think it's happening, a potential solution or how you've fixed a similar problem in the past. The person you are reviewing will really appreciate a solution oriented approach. &lt;/p&gt;

&lt;p&gt;Doing code reviews and having my own reviewed is great because it allows you and others to catch things you may not see because it's &lt;strong&gt;your code&lt;/strong&gt;. This in turn catches mistakes, bugs, and makes the code overall better developed.&lt;/p&gt;

&lt;p&gt;Happy reviewing!!!&lt;/p&gt;

&lt;p&gt;Andre&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>codereview</category>
    </item>
    <item>
      <title>Cross platform testing using Karma.</title>
      <dc:creator>Andre Willomitzer</dc:creator>
      <pubDate>Mon, 15 Nov 2021 21:45:35 +0000</pubDate>
      <link>https://dev.to/andrewillomitzer/cross-platform-testing-using-karma-193i</link>
      <guid>https://dev.to/andrewillomitzer/cross-platform-testing-using-karma-193i</guid>
      <description>&lt;h4&gt;
  
  
  What am I working on?
&lt;/h4&gt;

&lt;p&gt;The last 2-3 weeks I have been working on Pull Requests for my Open Source class at Seneca College. Previously, during Hacktoberfest I contributed to a tool called &lt;a href="https://github.com/kibertoad/toad-scheduler"&gt;toad-scheduler&lt;/a&gt; which is an in-memory NodeJS scheduling tool.&lt;/p&gt;

&lt;p&gt;In this tool, I helped fix a bug about setInterval() limit throwing an error with anything over than 24.5 days. During this PR, I had to write a test using &lt;code&gt;Jest&lt;/code&gt; framework to handle the long intervals and make sure it was firing the task correctly.&lt;/p&gt;

&lt;h4&gt;
  
  
  Different types of tests
&lt;/h4&gt;

&lt;p&gt;For my next PR, I wanted to work on the tool again with &lt;a href="https://github.com/kibertoad"&gt;Igor Savin&lt;/a&gt;. I asked him what I could do to help this time around. One of the options he mentioned was adding &lt;strong&gt;Browser based testing&lt;/strong&gt; using &lt;strong&gt;Headless Chrome&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I asked him why exactly we needed to do that considering there was already a full suite of Jest tests. His answer was that it was to prevent any "Node specific" functionality from creeping in to the code. This means we have to make sure the code works on any platform (command line, browser, etc).&lt;/p&gt;

&lt;h4&gt;
  
  
  Browser Testing With Karma
&lt;/h4&gt;

&lt;p&gt;Setting up Karma is actually quite straightforward thanks to the &lt;a href="http://karma-runner.github.io/6.3/index.html"&gt;documentation&lt;/a&gt; and provides step by step instructions on &lt;strong&gt;&lt;a href="http://karma-runner.github.io/6.3/intro/installation.html"&gt;installation&lt;/a&gt;&lt;/strong&gt;, and &lt;strong&gt;&lt;a href="http://karma-runner.github.io/6.3/config/configuration-file.html"&gt;configuration&lt;/a&gt;&lt;/strong&gt;. Furthermore, I used this &lt;a href="https://developers.google.com/web/updates/2017/06/headless-karma-mocha-chai"&gt;Google Dev Article&lt;/a&gt; about headless chrome setup.&lt;/p&gt;

&lt;p&gt;Since my task was the initial setup and writing a basic test, the test I decided to use in my Karma setup is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('a simple Karma test', () =&amp;gt; {
  it('should equal 2', () =&amp;gt; {
    expect(1 + 1).toBe(2)
  })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/kibertoad/toad-scheduler/pull/63/commits/37d5d07fc3591b655873dc93b389ff840c95efa6"&gt;Commit Links&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Interesting note about Jest &amp;amp; Karma
&lt;/h4&gt;

&lt;p&gt;However, because Jest is built on top and mostly compatible with Jasmine (which Karma is built on top of), the creator Igor had the idea to use the already predefined Jest tests but make them platform neutral. Take the Jest specific functions, and change them to be the Jasmine counterpart so that Karma can also run the tests originally made for Jest.&lt;/p&gt;

&lt;p&gt;An example of changing the functions is when advancing timers:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rKeczs7Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hhzbr6i3ar7edzh8gy0r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rKeczs7Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hhzbr6i3ar7edzh8gy0r.png" alt="Image description" width="880" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  How to run your tests?
&lt;/h4&gt;

&lt;p&gt;After following the setup for creating a &lt;code&gt;karma.conf.js&lt;/code&gt; and installing Karma with &lt;code&gt;npm&lt;/code&gt; you should be ready to write a basic test as I did above. Create a folder for your tests. Next, create a file with &lt;code&gt;.js&lt;/code&gt; or &lt;code&gt;.ts&lt;/code&gt; extension. Inside your test file, copy paste the &lt;code&gt;it/describe()&lt;/code&gt; from above. &lt;/p&gt;

&lt;p&gt;In the config file, in the "files" property, add the correct path to your test folder so Karma can find the test files. For us it was just called "test": &lt;br&gt;
&lt;code&gt;files: [{ pattern: 'test/**/*.ts' }, { pattern: 'lib/**/*.ts'}]&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Package.json script
&lt;/h4&gt;

&lt;p&gt;Inside &lt;code&gt;package.json&lt;/code&gt; under the scripts, add a new "test:karma" property or whatever name you prefer and set the value to the Karma test command like so:&lt;br&gt;
&lt;code&gt;"test:karma": "karma start --single-run --browsers ChromeHeadless karma.conf.js"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After saving and running &lt;code&gt;npm run test:karma&lt;/code&gt; on the command line it should run your test file. &lt;/p&gt;

&lt;h4&gt;
  
  
  Note
&lt;/h4&gt;

&lt;p&gt;An error I ran into doing this would be &lt;strong&gt;eslint&lt;/strong&gt; environment property needing &lt;code&gt;"browser":true&lt;/code&gt;. In some cases if you don't do this, it will not recognize export-default and cause an error with Karma in the command line.&lt;/p&gt;

&lt;h4&gt;
  
  
  What I learned
&lt;/h4&gt;

&lt;p&gt;I learned a lot about cross compatibility testing, and how to make multiple testing tools work together. It was interesting seeing the differences and also similarities between Jest/Jasmine/Karma. &lt;/p&gt;

&lt;p&gt;They all are related in some way so it was funny seeing that we didn't even need to write any more tests, just import the ones from Jest and change the functions to be Jasmine ones which Jest is able to understand too.&lt;/p&gt;

&lt;p&gt;I hope that helps someone get Karma tests up and running in their application!!!&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

&lt;p&gt;Andre&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Jest: execution testing &amp; automated setup.</title>
      <dc:creator>Andre Willomitzer</dc:creator>
      <pubDate>Fri, 12 Nov 2021 14:20:45 +0000</pubDate>
      <link>https://dev.to/andrewillomitzer/jest-execution-testing-automated-setup-502k</link>
      <guid>https://dev.to/andrewillomitzer/jest-execution-testing-automated-setup-502k</guid>
      <description>&lt;h3&gt;
  
  
  Why Test?
&lt;/h3&gt;

&lt;p&gt;When we write software or applications, generally we try to do it with the future in mind. By that I mean when you're writing code you already somewhat anticipate issues the user will create (for example, entering a letter where a number input should be), and you take steps to catch that error.&lt;/p&gt;

&lt;p&gt;But honestly, there is likely something that was missed. There are &lt;strong&gt;too many&lt;/strong&gt; possibilities to catch &lt;strong&gt;as you're writing the code&lt;/strong&gt;. That is where automated testing comes in. There are a variety of frameworks, but because my application is in NodeJS/JavaScript I picked Jest. I also have written 1 or 2 tests for it in the past so I was familiar with it() and describe().&lt;/p&gt;

&lt;h3&gt;
  
  
  What Is Jest?
&lt;/h3&gt;

&lt;p&gt;Jest is a testing framework used for writing unit tests for your application. It allows you to write tests and test suite files ending in &lt;code&gt;.test.js&lt;/code&gt; or &lt;code&gt;.spec.js&lt;/code&gt;. In these files, you are able to test individual pieces of your application. For example, in my &lt;a href="https://github.com/AndreWillomitzer/textToHTML_V2"&gt;textToHTML SSG&lt;/a&gt; I have a function that processes Markdown syntax, called... &lt;code&gt;processMarkdown()&lt;/code&gt;... I know, super creative.&lt;/p&gt;

&lt;p&gt;To install Jest, run &lt;code&gt;npm install --save-dev jest&lt;/code&gt; in your project folder. Then, as mentioned earlier create a &lt;code&gt;.spec.js&lt;/code&gt; file for your testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  How and What to Test?
&lt;/h3&gt;

&lt;p&gt;Because Markdown has so many symbols and combinations that can result in different HTML, I figured it would be a good idea to test different combinations in my tests. &lt;/p&gt;

&lt;p&gt;To test functionality, make sure to &lt;code&gt;require()&lt;/code&gt; or &lt;code&gt;include&lt;/code&gt; your file containing all the functions you want to test, and be sure to export them in that main file:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;const { processMarkdown, generatePara } = require("./textToHTML");&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;And then inside textToHTML: &lt;code&gt;module.exports = { processMarkdown, generatePara };&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example Test with processMarkdown()
&lt;/h3&gt;

&lt;p&gt;Here are a few examples of tests I wrote. &lt;code&gt;describe()&lt;/code&gt; is used to group tests into a suite, and can be used to organize WHAT the group of tests is testing. &lt;code&gt;it()&lt;/code&gt; can be used to run a single test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe("it should process various Markdown combinations", () =&amp;gt; {
  it("should handle a blank file", () =&amp;gt; {
    //testing if the input I give is blank (empty file but it exists)
    const emptyContent = "";
    const returnResult = processMarkdown(emptyContent);
    expect(returnResult).toMatch(""); //it should be blank if md.render() worked
  });

  it("should return a string", () =&amp;gt; {
    const testString = "";
    const returnResult = processMarkdown(testString);
    expect(typeof returnResult).toBe("string");
  });

  it("it should return h1", () =&amp;gt; {
    const testString = "# Should be inside h1.";
    const returnResult = processMarkdown(testString);
    const expectedResult = "&amp;lt;h1&amp;gt;Should be inside h1.&amp;lt;/h1&amp;gt;";
    expect(returnResult).toContain(expectedResult); 
  });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is only a small portion of the tests, but you can write as many as you want for whatever functionality you want in your program.&lt;/p&gt;

&lt;h3&gt;
  
  
  Okay great, but how do I run the test?
&lt;/h3&gt;

&lt;p&gt;To automate the tests, all you have to do is go into &lt;code&gt;package.json&lt;/code&gt; and add &lt;code&gt;"test": "jest"&lt;/code&gt;. Save the file and run &lt;code&gt;npm test&lt;/code&gt; from the command line. Voila! It should search for all .spec and .test files.&lt;/p&gt;

&lt;p&gt;To exclude a single test, you may go into the test file and change &lt;code&gt;it()&lt;/code&gt; to &lt;code&gt;xit()&lt;/code&gt;. To run only a single test or test suite, add &lt;code&gt;.only()&lt;/code&gt; to the end of the &lt;code&gt;describe()&lt;/code&gt; or &lt;code&gt;it()&lt;/code&gt; test you want to run.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I learned
&lt;/h3&gt;

&lt;p&gt;I learned a lot doing testing for the first time on my application, and I definitely plan to use more of it in the future. It promotes modular programming because you can't really test unless you have functions that handle smaller pieces of logic. Furthermore, it makes you really think about what the edge cases are in your program and how it SHOULD work vs. how it does.&lt;/p&gt;

&lt;p&gt;I hope that was helpful, &lt;br&gt;
Thanks for reading,&lt;br&gt;
Andre :)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Linting: Oxyclean for your code.</title>
      <dc:creator>Andre Willomitzer</dc:creator>
      <pubDate>Thu, 04 Nov 2021 18:23:01 +0000</pubDate>
      <link>https://dev.to/andrewillomitzer/linting-oxyclean-for-your-code-5jg</link>
      <guid>https://dev.to/andrewillomitzer/linting-oxyclean-for-your-code-5jg</guid>
      <description>&lt;h3&gt;
  
  
  Why Lint &amp;amp; Prettify?
&lt;/h3&gt;

&lt;p&gt;It's easy to forget that writing code is a creative practice like many others. When working on your application, you have a style. It's not something anyone taught you (some of it like basic syntax sure), but we all have our own ways to indent, write conditional statements, among other things. &lt;/p&gt;

&lt;p&gt;How would you explain your style to someone who hasn't seen you code before? Luckily, you don't have to when you use... &lt;strong&gt;&lt;em&gt;static analysis&lt;/em&gt;&lt;/strong&gt; tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools For The Job
&lt;/h3&gt;

&lt;p&gt;In my case, since the project is JavaScript based I have chosen &lt;a href="https://eslint.org/"&gt;eslint&lt;/a&gt;, and &lt;a href="https://prettier.io/"&gt;Prettier&lt;/a&gt; as the formatting and style guide tools. I chose them due to the popularity, and variety of setup guides which allows me to customize how I want. &lt;/p&gt;

&lt;h3&gt;
  
  
  Prettier Setup
&lt;/h3&gt;

&lt;p&gt;To set up Prettier, you will need to install the package from &lt;a href="https://www.npmjs.com/package/prettier"&gt;npm&lt;/a&gt; and using the instructions from &lt;a href="https://prettier.io/docs/en/install.html"&gt;Prettier Install Docs&lt;/a&gt;. This will set you up with a &lt;code&gt;.prettierrc.json&lt;/code&gt; file. In this file is where you will set all the &lt;a href="https://prettier.io/docs/en/options.html"&gt;configuration options&lt;/a&gt; for your Prettier formatting.&lt;/p&gt;

&lt;p&gt;Once the initial setup is done, you can choose which files to ignore by either creating a &lt;code&gt;.prettierignore&lt;/code&gt; file, or inputting which file to use as a base when you run the command using &lt;code&gt;--ignore-path&lt;/code&gt; CLI argument. &lt;/p&gt;

&lt;h3&gt;
  
  
  eslint setup
&lt;/h3&gt;

&lt;p&gt;To set up eslint, you can go to the &lt;a href="https://eslint.org/docs/user-guide/getting-started"&gt;getting started&lt;/a&gt; page which will show how to create a config file similar to Prettier. It also demonstrates how to set basic rules to get your linting started. More advanced configurations are available but getting started... gets you started.&lt;/p&gt;

&lt;p&gt;Similar to Prettier, you can create an &lt;strong&gt;&lt;em&gt;&lt;code&gt;.eslintignore&lt;/code&gt;&lt;/em&gt;&lt;/strong&gt; or specify --ignore-path when you run the &lt;code&gt;npm run eslint&lt;/code&gt; command.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I do that anyway?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Open package.json&lt;/li&gt;
&lt;li&gt;Create a new property under scripts called &lt;code&gt;"lint"&lt;/code&gt;, and set the value to "npm run eslint"&lt;/li&gt;
&lt;li&gt;Save the file and run &lt;code&gt;npm run lint&lt;/code&gt;!&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Bonus: .vscode config folder
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Create a folder called &lt;code&gt;.vscode&lt;/code&gt; in your project root directory.&lt;/li&gt;
&lt;li&gt;This folder can contain many files, but an example of one is &lt;code&gt;settings.json&lt;/code&gt; where you can set the rules for your VSCode editor such as auto-format on save, tab indenting, and more.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PSu9FBX6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hozu601g5hwvu5rpblom.png" alt="Image description" width="880" height="197"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What did it find in my own code?
&lt;/h3&gt;

&lt;p&gt;Having set up linting/formatting in my own SSG called &lt;a href="https://github.com/AndreWillomitzer/textToHTML_V2"&gt;textToHTML&lt;/a&gt;, &lt;a href="https://github.com/AndreWillomitzer/textToHTML_V2/commit/f9591ce0215c88c7da3b54bc34cc5cd704e937d4"&gt;commit link&lt;/a&gt;, I was curious what it would find.&lt;/p&gt;

&lt;p&gt;Mostly, it found spacing and line length issues. For example, when I generated my HTML template string, it split the string into multiple template strings separated by &lt;code&gt;+&lt;/code&gt;. Another thing I noticed was since I specified &lt;code&gt;"semi": true&lt;/code&gt; in the aforementioned config files, it added a couple missing semi-colons to the end of variable declarations. &lt;/p&gt;

&lt;p&gt;In terms of indenting/spacing nothing changed because I try to keep a consistent style and I set the rules up to match my own style (since I'm the project owner).&lt;/p&gt;

&lt;h3&gt;
  
  
  Moving Forward
&lt;/h3&gt;

&lt;p&gt;This was a great experience learning how to set up linting and formatting because in the future it will help others work on my project without having to ask how I want it done. I also now know how to set it up for future projects and where to find the setup docs.&lt;/p&gt;

</description>
      <category>opensource</category>
    </item>
    <item>
      <title>setInterval() and the 32 bit debacle.</title>
      <dc:creator>Andre Willomitzer</dc:creator>
      <pubDate>Sun, 31 Oct 2021 14:02:22 +0000</pubDate>
      <link>https://dev.to/andrewillomitzer/setinterval-and-the-32-bit-debacle-5bnm</link>
      <guid>https://dev.to/andrewillomitzer/setinterval-and-the-32-bit-debacle-5bnm</guid>
      <description>&lt;h2&gt;
  
  
  Backstory
&lt;/h2&gt;

&lt;p&gt;I first set out at the start of October to complete 4 Pull Requests for Hacktoberfest. My initial research led me to a tool called "Colorette" which is a CLI tool for coloring terminal output. I really wanted to work on this repository, but before I could implement my proposed issue fix, someone had swooped in and merged a PR in my place.&lt;/p&gt;

&lt;p&gt;Afterwards, a nice contributor to the project named &lt;a href="https://github.com/kibertoad" rel="noopener noreferrer"&gt;kibertoad&lt;/a&gt; saw this happen and asked if I wanted to come work on his &lt;a href="https://github.com/kibertoad/toad-scheduler" rel="noopener noreferrer"&gt;scheduling tool&lt;/a&gt;. I said sure, and off we went. There were very few issues in the repo because the tool had been tested well.&lt;/p&gt;

&lt;p&gt;However, &lt;a href="https://github.com/kibertoad/toad-scheduler/issues/24" rel="noopener noreferrer"&gt;one key issue remained&lt;/a&gt;. &lt;strong&gt;&lt;em&gt;setInterval()&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  setInterval()? What's the problem?
&lt;/h2&gt;

&lt;p&gt;You may think: "setInterval()? I've used that 1 million times no problem." and you would be right. The issue with setInterval() as we learned through the project is a problem with the JavaScript language itself. &lt;/p&gt;

&lt;p&gt;The value for setInterval is held in a 32 bit signed integer. Most times, the maximum is never exceeded because setInterval() is mainly used for executing tasks closer together. In our case however, it was discovered that because we are making a scheduling tool, someone may actually want to schedule a task for &lt;strong&gt;&lt;em&gt;30 days&lt;/em&gt;&lt;/strong&gt;, when the limit is &lt;strong&gt;&lt;em&gt;24.855 days.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Constructor Fixing
&lt;/h2&gt;

&lt;p&gt;Initially when creating a job and task with a schedule of 30 days, the tool would crash with a NodeJS error about the limit. In order to fix this, a lot of checking, delaying, and time-tracking had to be implemented in the constructor.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs48fz1mgywuzcj5mkzc6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs48fz1mgywuzcj5mkzc6.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, we set the future time to execute the task using the current time + the time the user schedules. Then, we create a task inside the SimpleIntervalJob itself. The purpose of this is so that when the task executes(wakes up) it will check if it's time to execute the original task, or if we're still over the limit. If we are, keep running the timeEating task. If we're not, then execute the task the user planned.&lt;/p&gt;

&lt;p&gt;By doing this, we "eat time" until setInterval() won't throw an error anymore. Overall, the most difficult part of this constructor fix was having to wrap my head around the &lt;strong&gt;&lt;em&gt;timeEating task calling itself&lt;/em&gt;&lt;/strong&gt; and checking &lt;strong&gt;&lt;em&gt;inside itself&lt;/em&gt;&lt;/strong&gt; whether were over time.&lt;/p&gt;
&lt;h2&gt;
  
  
  Testing
&lt;/h2&gt;

&lt;p&gt;Having seen the application code now, I noticed the creator was using &lt;strong&gt;&lt;em&gt;Jest&lt;/em&gt;&lt;/strong&gt; testing framework. Before this, I had no experience writing automated tests but if you're going to implement a fix you need to test so now was the time.&lt;/p&gt;

&lt;p&gt;For the most part, the tests consisted of a counter variable, and a job/task to be executed. In order to test if my constructor worked, I wrote a test that initialized a job to execute in 25 days (which is over the limit). I advanced the timer by just under 25 days, and then pushed it right to 25 days to check if the task executed properly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    it('correctly handles very large intervals', () =&amp;gt; {
      let counter = 0
      const daysInMs = 25 * 24 * 60 * 60 * 1000 //25 days in ms
      const scheduler = new ToadScheduler()
      const task = new Task('simple task', () =&amp;gt; {
        counter++
      })
      const job = new SimpleIntervalJob(
        {
          milliseconds: daysInMs,
        },
        task
      )
      scheduler.addSimpleIntervalJob(job)

      expect(counter).toBe(0)
      jest.advanceTimersByTime(daysInMs - 1000)
      expect(counter).toBe(0)
      jest.advanceTimersByTime(1000)
      expect(counter).toBe(1)
      scheduler.stop()
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Creator
&lt;/h2&gt;

&lt;p&gt;The original creator of the tool is &lt;a href="https://github.com/kibertoad" rel="noopener noreferrer"&gt;Igor 'kibertoad' Savin&lt;/a&gt; and I had a really great time getting to know him and picking his brain about this issue. Overall it was a very difficult issue to solve which is why I chose it for my &lt;a href="https://github.com/kibertoad/toad-scheduler/pull/53" rel="noopener noreferrer"&gt;4th Pull Request&lt;/a&gt; but I learned a lot about how to work around issues that you CAN'T fix at a base level such as the &lt;strong&gt;&lt;em&gt;32 bit integer not being big enough&lt;/em&gt;&lt;/strong&gt;. I might not be able to change the size of the integer but I can change how my code handles these issues.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Sometimes it's the little things (3rd PR).</title>
      <dc:creator>Andre Willomitzer</dc:creator>
      <pubDate>Sun, 31 Oct 2021 12:49:12 +0000</pubDate>
      <link>https://dev.to/andrewillomitzer/sometimes-its-the-little-things-3rd-pr-51hd</link>
      <guid>https://dev.to/andrewillomitzer/sometimes-its-the-little-things-3rd-pr-51hd</guid>
      <description>&lt;h3&gt;
  
  
  The Night of PR's Past
&lt;/h3&gt;

&lt;p&gt;In the month of October we are participating in Hacktoberfest. For my third pull request although it wasn't labelled for the competition, I decided to choose the Open Air Quality main website. In the past, I worked on the API that functions behind the scenes and removed some commented code from it.&lt;/p&gt;

&lt;p&gt;I decided to look again and see if there was another issue to work on but in a different repository for the same project. Doing so I found a very &lt;a href="https://github.com/openaq/openaq.org/issues/760"&gt;recent issue&lt;/a&gt; regarding one of the front end components of the application. &lt;/p&gt;

&lt;h3&gt;
  
  
  Doing Some Digging
&lt;/h3&gt;

&lt;p&gt;To fix this, I went into previous commits and PR's to see which files had been worked on for similar tasks. The bug was concerning the "comparison tool", and so I looked for commits and pulls saying they worked on compare/comparison features. By doing this I was able to find &lt;a href="https://github.com/openaq/openaq.org/blob/develop/app/assets/scripts/views/compare/compare-statistics.js"&gt;which file had the error&lt;/a&gt;. I had a strong feeling that since the issue was new, it may have been a more recent commit that made the spelling change.&lt;/p&gt;

&lt;p&gt;The fix itself was rather simple so I did not run into problems since the issue raised was a misspelling of "correlation" in the UI, but only in that 1 spot in that 1 file. Naturally I had a peek at the other files to make sure nothing else was spelled wrong by maybe even the same person. &lt;/p&gt;

&lt;h3&gt;
  
  
  Committing The Changes
&lt;/h3&gt;

&lt;p&gt;I cloned the app, made the &lt;a href="https://github.com/AndreWillomitzer/openaq.org/tree/issue-760"&gt;issue branch&lt;/a&gt;. After changing the mistake I committed, and made a &lt;a href="https://github.com/openaq/openaq.org/pull/764/commits/63542a43055879de1092069d0e9d6cca3403d083"&gt;Pull Request on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It was a good experience contributing to Open-AQ again in some way!&lt;/p&gt;

</description>
      <category>opensource</category>
    </item>
  </channel>
</rss>
