<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>CreepingCoder.com</title>
    <description>Doing the right thing, one step at a time!</description>
    <link>http://www.creepingcoder.com</link>
    <atom:link href="http://www.creepingcoder.com/feed.xml" rel="self" type="application/rss+xml" />
    
      <item>
        <title>Generate code coverage for .NET Core projects</title>
        <description>&lt;h2 id=&quot;what-is-code-coverage&quot;&gt;What is code coverage?&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;In computer science, test coverage is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs. A program with high test coverage, measured as a percentage, has had more of its source code executed during testing, which suggests it has a lower chance of containing undetected software bugs compared to a program with low test coverage.[1][2] Many different metrics can be used to calculate test coverage; some of the most basic are the percentage of program subroutines and the percentage of program statements called during execution of the test suite.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Source: &lt;a href=&quot;https://en.wikipedia.org/wiki/Code_coverage&quot;&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;should-i-care-about-code-coverage&quot;&gt;Should I care about code coverage?&lt;/h2&gt;

&lt;p&gt;Code coverage is a metric and as such it can be &lt;em&gt;used&lt;/em&gt; or &lt;em&gt;abused&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I’ve worked on projects where we’ve had 100% code coverage and I’ve worked on projects where we’ve had close to 0% code coverage. I prefer working on a codebase with a higher code coverage, it gives you more confidence that you won’t break everything with a “simple” change. Of course, the code coverage percentage and the confidence though correlated are not linearly correlated! Having a 100% code coverage doesn’t mean you can’t break something, it just provides you with a higher confidence you won’t do so.&lt;/p&gt;

&lt;h3 id=&quot;having-100-code-coverage&quot;&gt;Having 100% code coverage&lt;/h3&gt;

&lt;p&gt;As mentioned, this is just a metric and not having end-to-end tests won’t save you from production failures. Okay then, but then should I strive for 100% code coverage? The answer is - it depends. ;)&lt;/p&gt;

&lt;p&gt;It depends on your team, it depends on the product you’re building, it depends when you want to ship it, etc. Not all code coverage is the same, having 50% code coverage for non-critical features is less valuable than having 50% but having all your critical sections covered.&lt;/p&gt;

&lt;h4 id=&quot;legacy-projects&quot;&gt;Legacy projects&lt;/h4&gt;

&lt;p&gt;When working on legacy projects with a low code coverage - your goal should be to &lt;strong&gt;increase the code coverage&lt;/strong&gt; (or at least not to decrease it!). It’s not realistic to go from 20% to 100% overnight. Reaching 100% on a relatively big project is a big effort and would definitely require change of the project priorities.&lt;/p&gt;

&lt;p&gt;I have 2 simple rules which I try to follow when working on such projects:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Add a test for any newly written code.&lt;/li&gt;
  &lt;li&gt;Add a test when you change “old” code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Don’t be mistaken, simple doesn’t mean easy. Not having tests probably means it’s not really straight-forward adding such, because if it were that easy - probably somebody else would have probably already done it. It’s important to take time and add such tests if you consider this part of the code critical, if not - then you could probably skip it, but be ready to go back and fix it again. :)&lt;/p&gt;

&lt;h4 id=&quot;new-projects&quot;&gt;New projects&lt;/h4&gt;

&lt;p&gt;Everybody loves new projects. Starting a new project fills you enthusiasm and we’re thinking “i am going to do it right this time!”. More often than not - we’re doing the same mistakes over and over again. It’s important to lay the right foundations (and restrictions) from the beginning. Having strict rules is great when you don’t have to worry of 5-years worth of code!&lt;/p&gt;

&lt;p&gt;You can configure the linter exactly how you won’t and you won’t rewrite the history of practically every file under source control (or do stupid git hacks to workaround it).&lt;/p&gt;

&lt;p&gt;You can have a hard-rule for the code coverage and while you are it - just have it at 100%! But why should it be 100% and not 95%, but what about 90% or 75%? You get the point, having the choice will always start discussions. It’s black/white rules. Having the code coverage at 100% - doesn’t mean you need to have a 100% code coverage, but it means by default you should cover your newly written code, if a new piece of code can’t be instrumented - then this would be the exception, not the rule! Note also, that having 100% code coverage doesn’t mean you’ve tested all the cases, it means all branches’ code has been executed, but you may have not actually asserted anything and everything can be wrapped in a &lt;code class=&quot;highlighter-rouge&quot;&gt;try&lt;/code&gt;/&lt;code class=&quot;highlighter-rouge&quot;&gt;catch&lt;/code&gt; block. This will fool the tooling, but that’s not what we want, right? :)&lt;/p&gt;

&lt;p&gt;Having black/white rules is very useful for linting as well - just break the build if you have 1 or more warnings or errors - no discussions there! Yeah, have a discussion what constitutes an error for your project, but don’t start a flame war how many errors is OK to have.&lt;/p&gt;

&lt;p&gt;The whole point of the tooling is to minimize the trivial comments in PRs, have the tools do the heavy-lifting, this way you enable the developers to focus on the really important parts of the code - not on technical details as why is this not properly indented, there are tabs instead of spaces, etc.&lt;/p&gt;

&lt;h2 id=&quot;unit-tests-and-net-core&quot;&gt;Unit tests and .NET Core&lt;/h2&gt;

&lt;p&gt;Running tests with &lt;code class=&quot;highlighter-rouge&quot;&gt;dotnet&lt;/code&gt; CLI is really simple, but has a minor difference than using &lt;code class=&quot;highlighter-rouge&quot;&gt;vstest&lt;/code&gt; console runner - you need to pass a project file and not an assembly! What this means you can’t tests from multiple assemblies with a single command. That’s a shame… Good we’ve MSBuild built into &lt;code class=&quot;highlighter-rouge&quot;&gt;dotnet&lt;/code&gt; so we can hack our way around it! If you have missed the previous post - &lt;a href=&quot;/2020/06/14/msbuild-101-using-the-exit-codes-from-multiple-commands/&quot;&gt;go check it out&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;running-the-tests&quot;&gt;Running the tests&lt;/h3&gt;

&lt;p&gt;All you need to do is the following in the directory of the test project:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dotnet &lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;or if you are in the root solution dir&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dotnet &lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt; &amp;lt;project_path&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;collecting-code-coverage&quot;&gt;Collecting code coverage&lt;/h3&gt;

&lt;p&gt;It’s as simple as adding &lt;code class=&quot;highlighter-rouge&quot;&gt;--collect:&quot;Code Coverage&quot;&lt;/code&gt; to the &lt;code class=&quot;highlighter-rouge&quot;&gt;dotnet test&lt;/code&gt; command!&lt;/p&gt;

&lt;p&gt;Unfortunately, there are a couple of gotchas you need to consider.&lt;/p&gt;

&lt;h4 id=&quot;running-on-non-windows-os&quot;&gt;Running on non-Windows OS&lt;/h4&gt;

&lt;p&gt;You need to run on Windows or you would get the following error:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Data collector 'Code Coverage' message: No code coverage data available. Code coverage is currently supported only on Windows..
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That’s a downer, but it should be fixed sometime in the future. Check &lt;a href=&quot;https://github.com/microsoft/vstest/issues/981&quot;&gt;this&lt;/a&gt; GitHub issue if you want to track the progress of this.&lt;/p&gt;

&lt;p&gt;In the meantime, you can use &lt;code class=&quot;highlighter-rouge&quot;&gt;coverlet.collector&lt;/code&gt;. You add it as a reference to the test project and change the command collector type from &lt;code class=&quot;highlighter-rouge&quot;&gt;Code Coverage&lt;/code&gt; to &lt;code class=&quot;highlighter-rouge&quot;&gt;XPlat Code Coverage&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here is the whole command, for example:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dotnet &lt;span class=&quot;nb&quot;&gt;test &lt;/span&gt;Lib.Tests/Lib.Tests.csproj  &lt;span class=&quot;nt&quot;&gt;--collect&lt;/span&gt;:&lt;span class=&quot;s2&quot;&gt;&quot;XPlat Code Coverage&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;* Not sure if coverlet results file is supported by Azure DevOps or you need to convert it.&lt;/p&gt;

&lt;p&gt;If you are building on Windows, just use the first command as it can generate the TRX files and the code coverage files which can be seamlessly published to the Azure DevOps. Probably there are plugins (maybe called tasks?) that can parse the &lt;strong&gt;Cobertura&lt;/strong&gt; format, not sure. Why am I mentioning Azure DevOps - well, this was the CI provider I use, so I solved for my problem. :)&lt;/p&gt;

&lt;h4 id=&quot;updating-the-microsoftnettestsdk-package&quot;&gt;Updating the Microsoft.NET.Test.Sdk package&lt;/h4&gt;

&lt;p&gt;Make sure you are running the latest version of this package or you are likely to have issues. If you don’t have the package explicitly listed - add the latest version of it!&lt;/p&gt;

&lt;h3 id=&quot;running-tests-as-part-of-ci&quot;&gt;Running tests as part of CI&lt;/h3&gt;

&lt;p&gt;And we come to the final part. We’re going to leverage the knowledge from the previous post and this one to have a working MSBuild script executing the tests from all of our test projects. Generating code coverage as well and erroring out if we have any failing tests. I am just going to add the code as I think it’s pretty self-explanatory.&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;DotNetCoreTestProjects&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Include=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;$(SolutionDirectory)\**\*tests.csproj&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;DotNetCoreTestArgs&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Include=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;--verbosity:normal&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Default verbosity is &quot;minimal&quot; --&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;DotNetCoreTestArgs&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Include=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;--no-build&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;          &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- If you've already built the solution you can safely add this --&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;DotNetCoreTestArgs&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Include=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;--logger:trx&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;        &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Add the TRX logger so we can publish the test reults --&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;DotNetCoreTestArgs&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Include=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;--results-directory:&amp;amp;quot;$(TestResultsOutputDir)&amp;amp;quot;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;DotNetCoreTestArgs&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Include=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;--collect:&amp;amp;quot;Code Coverage&amp;amp;quot;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;UnitTestExecutionExitCodes&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;Exec&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Command=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;dotnet test %(DotNetCoreTestProjects.FullPath) @(DotNetCoreTestArgs, ' ')&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;ContinueOnError=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;Output&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;TaskParameter=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ExitCode&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;ItemName=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;UnitTestExecutionExitCodes&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Exec&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;Error&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Text=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Unit test execution failed!&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot; '%(UnitTestExecutionExitCodes.Identity)' != '0' &quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The snippet above will execute the &lt;code class=&quot;highlighter-rouge&quot;&gt;dotnet test&lt;/code&gt; command and all the defined arguments for each test project matching the &lt;code class=&quot;highlighter-rouge&quot;&gt;**\*tests.csproj&lt;/code&gt; search pattern. No need to update the script if you add a new test project which name ends with &lt;code class=&quot;highlighter-rouge&quot;&gt;Tests.csproj&lt;/code&gt;. That’s pretty sweet, we want to have script that we write once and don’t touch anymore. If you need to touch it every time you add a new project - chances are you are going to forget to do it and your tests won’t get executed! Having conventions for naming the test projects is useful in on itself, but not having the need to touch the script is a stronger reason.&lt;/p&gt;

&lt;p&gt;I want to draw your attention to the &lt;code class=&quot;highlighter-rouge&quot;&gt;ContinueOnError=true&lt;/code&gt; - that’s pretty important as mentioned before, we want to execute all tests and THEN fail (if there are failing ones). That’s important so you can see all failing tests on the first run! If you have failing tests in multiple projects, we’re going to get the errors one by one for each successive run and we don’t want that.&lt;/p&gt;

&lt;h2 id=&quot;closing-thoughts&quot;&gt;Closing thoughts&lt;/h2&gt;

&lt;p&gt;I’ve always been a proponent having my build scripts in the source control and not in the CI tool, be it TFS, Azure DevOps, Jenkins, TeamCity or whatever. Yeah, the tools have history as well (they didn’t before), but you are coupling branches and builds which is bad. Any change you need to make would require you to sync things in 2 places - source code and CI tool! Just move everything in a single place - the source control. You can have per-branch changes that won’t affect every other branch there is.&lt;/p&gt;

&lt;p&gt;Of course - you can go with Azure Pipelines (YAML) for example - it’s per branch and is stored in source control as well, but you can’t really run the script locally. Yeah, probably there are some tools that will do that for you, but it’s another thing you need to think about and check if everything is really supported. MSBuild gives you the flexibility to experiment with the scripts locally (almost an instantaneous feedback loop), no need to wait for build agents, source retrieval, etc. You can easily comment-out unneeded steps to speed-up the feedback loop even more! And most importantly - you have environment-agnostic scripts - you can execute them locally or somewhere else, they should behave the same as MSBuild will be the same on all the environments. Yeah, MSBuild is not easy/fun to write, but it’s definitely better than YAML. YAML is not made to be written by humans, but to be automatically generated (prove me wrong).&lt;/p&gt;

&lt;p&gt;I’ve been using this script for 3+ weeks now and I haven’t touched it! 3 weeks may not sound like much, but new test projects were added, old ones were moved and everything is still working as in the beginning, so I say this works well enough for my case! ;)&lt;/p&gt;
</description>
        <pubDate>Sun, 21 Jun 2020 00:00:00 +0300</pubDate>
        <link>http://www.creepingcoder.com/2020/06/21/generate-code-coverage-for-dot-net-core-projects/</link>
        <guid isPermaLink="true">http://www.creepingcoder.com/2020/06/21/generate-code-coverage-for-dot-net-core-projects/</guid>
      </item>
    
      <item>
        <title>MSBuild 101: Using the exit codes from multiple commands</title>
        <description>&lt;p&gt;A continuation of the &lt;a href=&quot;/2020/06/01/msbuild-101-using-the-exit-code-from-a-command/&quot;&gt;previous post&lt;/a&gt;. Today we’re going to take a look how we can execute multiple commands with MSBuild.&lt;/p&gt;

&lt;p&gt;Hopefully, you took the time to familiarize yourself with the MSBuild concepts listed in the previous post, if not - &lt;a href=&quot;/2020/06/01/msbuild-101-using-the-exit-code-from-a-command/&quot;&gt;go check it out&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;executing-multiple-external-commands&quot;&gt;Executing multiple external commands&lt;/h2&gt;

&lt;p&gt;Last time we wanted to execute a single command and check its error code, although useful, it’s kinda limited. Usually, we want to execute a set of commands instead of a single one.&lt;/p&gt;

&lt;h3 id=&quot;the-copypaste-way&quot;&gt;The copy/paste way&lt;/h3&gt;

&lt;p&gt;Remember - your first job is to get the everything working, refactoring and optimization come after that!&lt;/p&gt;

&lt;p&gt;Here is the simplest way to do it:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;Exec&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Command=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;echo foobar&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;Exec&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Command=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;echo zaz&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;more-of-msbuild-way&quot;&gt;More of “MSBuild” way&lt;/h3&gt;

&lt;p&gt;Although we can define a single &lt;code class=&quot;highlighter-rouge&quot;&gt;exec&lt;/code&gt; task, we can use it to iterate through a list of commands, like so:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Commands&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Include=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;echo foobar;
                       echo zaz&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;Exec&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Command=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;%(Commands.Identity)&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now that’s more lines, however, we only need to touch the commands item group, no need to copy/paste the &lt;code class=&quot;highlighter-rouge&quot;&gt;exec&lt;/code&gt; task!&lt;/p&gt;

&lt;p&gt;Of course, you can get away when you know all your items (or commands), however that may not always be the case. Then you can’t go with the copy/paste way. :(&lt;/p&gt;

&lt;h2 id=&quot;check-the-exit-codes&quot;&gt;Check the exit codes&lt;/h2&gt;

&lt;p&gt;Now that we’ve executed multiple commands we may want to check their exit codes. In my previous post we checked the exit code of a single command. That’s pretty easy, we write it to a property, but we don’t have a single command now, we have multiple commands. That means a property won’t suffice.We can leverage an item group for this use case!&lt;/p&gt;

&lt;p&gt;Here how this can be done:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Commands&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Include=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;echo foobar;
                       echo zaz&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;Exec&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Command=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;%(Commands.Identity)&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;ContinueOnError=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Output&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;TaskParameter=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ExitCode&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;ItemName=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ExitCodes&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Exec&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;Message&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Text=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ExitCodes: @(ExitCodes)&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If you run the snippet above, you’re going to get the following output in the console:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;foobar
zaz
ExitCodes: 0;0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;* Do note the &lt;code class=&quot;highlighter-rouge&quot;&gt;ContinueOnError&lt;/code&gt; attribute, if you omit this, only the first command will be executed in case of an error!&lt;/p&gt;

&lt;h3 id=&quot;rule-of-thumb&quot;&gt;Rule of thumb&lt;/h3&gt;

&lt;p&gt;If you need more than 1 property - use an item group!&lt;/p&gt;

&lt;h3 id=&quot;bubble-up-the-error&quot;&gt;Bubble-up the error&lt;/h3&gt;

&lt;p&gt;If you want to bubble-up the error, you can add an &lt;code class=&quot;highlighter-rouge&quot;&gt;Error&lt;/code&gt; task as follows:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;Error&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Text=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Command execution failed!&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot; '%(ExitCodes.Identity)' != '0' &quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will go through every item (&lt;code class=&quot;highlighter-rouge&quot;&gt;0;0&lt;/code&gt;) in the item group (remember, items printed with a semi-colon delimiter) and check if it’s different than &lt;code class=&quot;highlighter-rouge&quot;&gt;0&lt;/code&gt;, if it is - &lt;code class=&quot;highlighter-rouge&quot;&gt;Command execution failed!&lt;/code&gt; error will be raised.&lt;/p&gt;

&lt;h2 id=&quot;final-words&quot;&gt;Final words&lt;/h2&gt;

&lt;p&gt;This is you can execute multiple commands and fail after each one of the commands is executed.&lt;/p&gt;

&lt;p&gt;Next time we’re going to use the knowledge to actually do something useful!&lt;/p&gt;
</description>
        <pubDate>Sun, 14 Jun 2020 00:00:00 +0300</pubDate>
        <link>http://www.creepingcoder.com/2020/06/14/msbuild-101-using-the-exit-codes-from-multiple-commands/</link>
        <guid isPermaLink="true">http://www.creepingcoder.com/2020/06/14/msbuild-101-using-the-exit-codes-from-multiple-commands/</guid>
      </item>
    
      <item>
        <title>MSBuild 101: Using the exit code from a command</title>
        <description>&lt;p&gt;MSBuild is a really interesting beast! He who has not used it haven’t encountered its quirks!&lt;/p&gt;

&lt;h2 id=&quot;should-i-care-about-msbuild&quot;&gt;Should I care about MSBuild?&lt;/h2&gt;

&lt;p&gt;If you are working on a .NET stuff, you definitely should know how it works, because the whole .NET ecosystem is built around it. From your project files (e.g. &lt;code class=&quot;highlighter-rouge&quot;&gt;csproj&lt;/code&gt;) all the way down to all Microsoft &lt;code class=&quot;highlighter-rouge&quot;&gt;targets&lt;/code&gt;. Varying from what should go to the intermediate (&lt;code class=&quot;highlighter-rouge&quot;&gt;obj&lt;/code&gt;) dir and what to the output (&lt;code class=&quot;highlighter-rouge&quot;&gt;bin&lt;/code&gt;), copying references (if needed) or even publishing a self-contained executable (if using .NET Core).&lt;/p&gt;

&lt;p&gt;Basically, there is not way around it! Love it or hate it - you are going to use it.&lt;/p&gt;

&lt;h2 id=&quot;msbuild-101&quot;&gt;MSBuild 101&lt;/h2&gt;

&lt;p&gt;Before continuing, you should familiarize yourself with 2 core concepts:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-properties&quot;&gt;Properties&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-items&quot;&gt;Items&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-task-reference&quot;&gt;Tasks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those are the 3 building blocks of MSBuild.&lt;/p&gt;

&lt;p&gt;If you don’t want to dig in, just remember this:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Properties are used for a single value (e.g. path to a config file).&lt;/li&gt;
  &lt;li&gt;Items (or items groups) are used for multiple values (e.g. list of all project files).&lt;/li&gt;
  &lt;li&gt;Tasks do the actual work (executing commands, copying stuff, etc).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;execute-an-external-command&quot;&gt;Execute an external command&lt;/h2&gt;

&lt;p&gt;Executing an external command in MSBuild is pretty easy, we need to just use the &lt;code class=&quot;highlighter-rouge&quot;&gt;exec&lt;/code&gt; &lt;em&gt;task&lt;/em&gt; like so:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;Exec&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Command=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;echo foobar&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Pretty simple and of course - pretty useless!&lt;/p&gt;

&lt;h3 id=&quot;check-the-exit-code&quot;&gt;Check the exit code&lt;/h3&gt;

&lt;p&gt;In a lot of scenarios you want to check the exit code:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;Exec&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Command=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;myecho foobar&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;ContinueOnError=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Output&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;TaskParameter=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ExitCode&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;PropertyName=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;MyEchoExitCode&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Exec&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will set the &lt;code class=&quot;highlighter-rouge&quot;&gt;MyEchoExitCode&lt;/code&gt; &lt;em&gt;property&lt;/em&gt; to &lt;code class=&quot;highlighter-rouge&quot;&gt;127&lt;/code&gt; if running on &lt;strong&gt;MacOS&lt;/strong&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;9009&lt;/code&gt; if running on &lt;strong&gt;Windows&lt;/strong&gt; for &lt;em&gt;command not found&lt;/em&gt; (unless you have &lt;code class=&quot;highlighter-rouge&quot;&gt;myecho&lt;/code&gt; executable in your &lt;code class=&quot;highlighter-rouge&quot;&gt;PATH&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Note the &lt;code class=&quot;highlighter-rouge&quot;&gt;ContinueOnError&lt;/code&gt; part - if omitted the script will fail and the execution will stop. You can think of it as a &lt;code class=&quot;highlighter-rouge&quot;&gt;try&lt;/code&gt;/&lt;code class=&quot;highlighter-rouge&quot;&gt;catch&lt;/code&gt; block!&lt;/p&gt;

&lt;p&gt;* You can check more options for the &lt;a href=&quot;https://docs.microsoft.com/en-us/visualstudio/msbuild/exec-task&quot;&gt;exec&lt;/a&gt; task.&lt;/p&gt;

&lt;h3 id=&quot;act-accordingly&quot;&gt;Act accordingly&lt;/h3&gt;

&lt;p&gt;Having captured the exit code was the hard part! Now comes the easy part - doing stuff with the result you’ve got.&lt;/p&gt;

&lt;p&gt;Having repeatable build process is a MUST, but you can spice it up with the following snippet:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;PropertyGroup&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;IsBlueMoon&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot; '$([System.DateTime]::Now.ToString(ss))' == '59' &quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;true&lt;span class=&quot;nt&quot;&gt;&amp;lt;/IsBlueMoon&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;Exec&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Command=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;build my.project&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;ContinueOnError=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Output&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;TaskParameter=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ExitCode&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;PropertyName=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;BuildExitCode&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Exec&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;Error&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Message=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;BUILD FAILED!&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot; '$(BuildExitCode)' != '0' AND '$(IsBlueMoon)' != 'true' &quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This way your build won’t fail when there is a blue moon outside!&lt;/p&gt;

&lt;h2 id=&quot;final-words&quot;&gt;Final words&lt;/h2&gt;

&lt;p&gt;That was a basic example of how you can use MSBuild to execute a custom command and check the exit code.&lt;/p&gt;

&lt;p&gt;Next time, we’re going to leverage this to actually do some useful stuff! ;)&lt;/p&gt;
</description>
        <pubDate>Mon, 01 Jun 2020 00:00:00 +0300</pubDate>
        <link>http://www.creepingcoder.com/2020/06/01/msbuild-101-using-the-exit-code-from-a-command/</link>
        <guid isPermaLink="true">http://www.creepingcoder.com/2020/06/01/msbuild-101-using-the-exit-code-from-a-command/</guid>
      </item>
    
      <item>
        <title>Finding wrong reference hint paths in C#</title>
        <description>&lt;p&gt;I am back in the &lt;strong&gt;.NET&lt;/strong&gt; world in the last couple of months. This is after almost 2 years break I took from C#. ;)&lt;/p&gt;

&lt;p&gt;A lot has changed and yet, everything is the same! Yeah, yeah, I am not working with &lt;strong&gt;.NET Core&lt;/strong&gt;, but still…&lt;/p&gt;

&lt;p&gt;The project I am working on uses the legacy &lt;code class=&quot;highlighter-rouge&quot;&gt;Reference&lt;/code&gt;, not the shiny new &lt;code class=&quot;highlighter-rouge&quot;&gt;PackageReference&lt;/code&gt; (&lt;a href=&quot;https://docs.microsoft.com/en-us/nuget/consume-packages/migrate-packages-config-to-package-reference&quot;&gt;more info&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The good news is we plan to migrate to &lt;code class=&quot;highlighter-rouge&quot;&gt;PackageReference&lt;/code&gt; usage, but things are not so simple. The main reason is you need to migrate all projects all at once, because VisualStudio doesn’t play well with mixed usage, which is expected after many years in the Microsoft eco-system.&lt;/p&gt;

&lt;p&gt;The bad news is upgrading 70+ projects is not a trivial task. Having “zombie” references (not used by anyone) is not helping either.&lt;/p&gt;

&lt;h2 id=&quot;building-a-fresh-repo-was-failing&quot;&gt;Building a fresh repo was failing&lt;/h2&gt;

&lt;h3 id=&quot;using-assemblies-from-other-project-output-directories&quot;&gt;Using assemblies from other project output directories&lt;/h3&gt;

&lt;p&gt;If you got a fresh repo copy and try to build the solution - it was failing. The reason for this was some references were pointing to the &lt;code class=&quot;highlighter-rouge&quot;&gt;bin/Debug&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;bin/Release&lt;/code&gt; directories of other projects.&lt;/p&gt;

&lt;p&gt;Of course, from experience, if something is messed-up on one place, most likely it’s not the only one. So, I I searched throughout all the project files:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;HintPath&amp;gt;((?!packages).)*&amp;lt;\/HintPath&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is a regex search*, which finds all &lt;code class=&quot;highlighter-rouge&quot;&gt;HintPath&lt;/code&gt; tags NOT containing &lt;code class=&quot;highlighter-rouge&quot;&gt;packages&lt;/code&gt; string inside them.&lt;/p&gt;

&lt;p&gt;* &lt;em&gt;Make sure to enable regex search in VisualStudio. I use VS Code when manually editing project because there is no need to unload them.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;using-net-standard-references&quot;&gt;Using &lt;strong&gt;.NET Standard&lt;/strong&gt; references&lt;/h3&gt;

&lt;p&gt;Now, there were cases where &lt;strong&gt;.NET Standard&lt;/strong&gt; references were used when there is a full framework alternative already built. For that I used the following pattern:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;HintPath&amp;gt;(.*)?(netstandard)(.*)?&amp;lt;\/HintPath&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Note that not everything containing &lt;code class=&quot;highlighter-rouge&quot;&gt;netstandard&lt;/code&gt; should be changed, but there are cases where you want to use the full framework assembly, so you don’t pull all the &lt;strong&gt;.NET Standard&lt;/strong&gt; dependencies in your output dir. This is a manual process if you don’t want to reinstall a given package. ;)&lt;/p&gt;

&lt;p&gt;We had a couple of those, note that using a wrong assembly may generate a wrong binding redirect build time (the so called - unifying), which can “magically” break your application on testing/production environments. I don’t know why this is enabled by default, but it’s something to keep on the back of your mind.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;For now, we’ve fixed our immediate issues. It’s time consuming as each time you install a new package, you have 3 files you need to take care of:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;project file&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;packages.config&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;app.config&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;web.config&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of course, there are issues with the so called binding redirect, Microsoft messed up their versioning on some of the assemblies which generates a lot of manual work every time you use NuGet through the VisualStudio interface. :(&lt;/p&gt;

&lt;p&gt;This becomes pain in the butt when you have 70+ projects and a lot of people working, because usually you touch a lot of files when you fix any issues package/reference issues.&lt;/p&gt;

&lt;p&gt;Good thing is NuGet is now fully integrated in VisualStudio 2017 or later. I remember using NuGet way back in the day was painful and they alleviated some of the pain, but &lt;strong&gt;.NET&lt;/strong&gt; hasn’t really solved the issue with different package versions. You can check this &lt;a href=&quot;https://codeblog.jonskeet.uk/2019/10/25/options-for-nets-versioning-issues/&quot;&gt;very interesting blog post&lt;/a&gt; by Jon Skeet. I believe this causes a lot of weird behavior described above.&lt;/p&gt;

&lt;p&gt;Maybe I can write something about using &lt;code class=&quot;highlighter-rouge&quot;&gt;PackageReferences&lt;/code&gt; and binding redirects in another post. There is a lot to share there as well. Stay tuned! :)&lt;/p&gt;
</description>
        <pubDate>Sun, 09 Feb 2020 00:00:00 +0200</pubDate>
        <link>http://www.creepingcoder.com/2020/02/09/finding-wrong-reference-hint-paths-in-c-sharp/</link>
        <guid isPermaLink="true">http://www.creepingcoder.com/2020/02/09/finding-wrong-reference-hint-paths-in-c-sharp/</guid>
      </item>
    
      <item>
        <title>Fixing random color changes on Catalina</title>
        <description>&lt;p&gt;After I’ve upgraded to &lt;strong&gt;MacOS Catalina&lt;/strong&gt; I started experiencing really weird color changes.&lt;/p&gt;

&lt;p&gt;For example, I am working in the afternoon (2PM) and my colors get “yellowish” and after 5 seconds it goes to its normal colors. Of course, my first though was, hey (f.lux)[https://justgetflux.com/] is playing tricks on me, but I was wrong.&lt;/p&gt;

&lt;h2 id=&quot;the-problem&quot;&gt;The problem&lt;/h2&gt;

&lt;p&gt;It seems with &lt;strong&gt;Catalina&lt;/strong&gt;, Apple introduced the so called (True Tone)[https://support.apple.com/en-us/HT208909]. How this feature works you may ask? Well, from my understanding it reads a sensor located in the front camera and checks if it’s day or night. If it’s night it uses warmer colors (this should make you fall asleep easier, you know). However, this doesn’t work well if the sun is blocked by a cloud, because the color change is triggered.&lt;/p&gt;

&lt;h2 id=&quot;the-solution&quot;&gt;The solution&lt;/h2&gt;

&lt;p&gt;Well, just disable the &lt;strong&gt;True Tone&lt;/strong&gt; as it’s described in the article above.&lt;/p&gt;

&lt;h2 id=&quot;why-use-flux&quot;&gt;Why use f.lux?&lt;/h2&gt;

&lt;p&gt;As I mentioned, it’s supposed to help you fall asleep easier. Personally, I don’t have hard time doing so and I am not sure if that’s because of &lt;strong&gt;f.lux&lt;/strong&gt;, but generally it seems like a good idea not to use bright screen late in the evening.&lt;/p&gt;

&lt;p&gt;Also, I am wearing glasses that have some kind of a blue filter, which is readily visible when reading my &lt;strong&gt;Kindle&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I use the recommended settings of &lt;strong&gt;f.lux&lt;/strong&gt;, which means when the sun is set all the colors are warmer. I’ve enabled the &lt;code class=&quot;highlighter-rouge&quot;&gt;OS X dark theme at sunset&lt;/code&gt;, which is kinda nice indicator for the end of the work day. :)&lt;/p&gt;
</description>
        <pubDate>Sun, 08 Dec 2019 00:00:00 +0200</pubDate>
        <link>http://www.creepingcoder.com/2019/12/08/fixing-random-color-changes-on-catalina/</link>
        <guid isPermaLink="true">http://www.creepingcoder.com/2019/12/08/fixing-random-color-changes-on-catalina/</guid>
      </item>
    
      <item>
        <title>Using nvm and nodenv side-by-side</title>
        <description>&lt;p&gt;If you’ve read my last &lt;a href=&quot;/2019-09-28-start-using-prezto/&quot;&gt;post&lt;/a&gt;, you know that
I’ve switched to using &lt;code class=&quot;highlighter-rouge&quot;&gt;nodenv&lt;/code&gt; from &lt;code class=&quot;highlighter-rouge&quot;&gt;nvm&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;why&quot;&gt;Why?&lt;/h2&gt;

&lt;p&gt;I don’t want to explain again, so you can &lt;a href=&quot;/2019-09-28-start-using-prezto/#set-your-nodejs-environment&quot;&gt;read more&lt;/a&gt; about it.&lt;/p&gt;

&lt;h2 id=&quot;the-problem&quot;&gt;The problem&lt;/h2&gt;

&lt;p&gt;Running the project with different versions of &lt;strong&gt;NodeJS&lt;/strong&gt; may lead to unexpected results. This is especially true if we are talking about projects where more than 1 person is working on. But it holds true for personal projects that have been on the back-burner for some time.&lt;/p&gt;

&lt;p&gt;Don’t forget this timeless quote:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Source from &lt;a href=&quot;https://stackoverflow.com/questions/876089/who-wrote-this-programing-saying-always-code-as-if-the-guy-who-ends-up-maintai&quot;&gt;StackOverflow&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Speaking from my personal experience, 99% of the time, the person knows where you live! Because this person is you! Yep, the person who wrote this “ugly piece of shit” was old me!&lt;/p&gt;

&lt;p&gt;So… make sure you’ve done the best to your abilities to soothe the next person who’s gonna work on it. :)&lt;/p&gt;

&lt;h2 id=&quot;the-solution&quot;&gt;The solution&lt;/h2&gt;

&lt;p&gt;If &lt;code class=&quot;highlighter-rouge&quot;&gt;nvm&lt;/code&gt; is already adopted on your team - great! It’s a step in the right direction, also, good amount of CI providers have support for it (e.g. &lt;a href=&quot;https://github.com/Almouro/bitrise-nvm-step&quot;&gt;Bitrise&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Add an &lt;code class=&quot;highlighter-rouge&quot;&gt;.nvmrc&lt;/code&gt; file with the following content: &lt;code class=&quot;highlighter-rouge&quot;&gt;10.16.3&lt;/code&gt; (this is current &lt;code class=&quot;highlighter-rouge&quot;&gt;LTS&lt;/code&gt; version, but probably won’t be by the time you read this).&lt;/p&gt;

&lt;p&gt;Now, you want to have a &lt;code class=&quot;highlighter-rouge&quot;&gt;.node-version&lt;/code&gt; file with the same content. But although &lt;code class=&quot;highlighter-rouge&quot;&gt;copy&lt;/code&gt;/&lt;code class=&quot;highlighter-rouge&quot;&gt;paste&lt;/code&gt; is the best tool in a developers toolbox, it’s not the right tool for our job.&lt;/p&gt;

&lt;p&gt;You want to symlink &lt;code class=&quot;highlighter-rouge&quot;&gt;.node-version&lt;/code&gt; to &lt;code class=&quot;highlighter-rouge&quot;&gt;.nvmrc&lt;/code&gt;, in order to do so, execute the following command in the root directory of your repo:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; .nvmrc .node-version
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, if you execute &lt;code class=&quot;highlighter-rouge&quot;&gt;ls -la&lt;/code&gt; then you should something like that:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;❯ ls -l .node-version
lrwxr-xr-x  1 steliyan  staff  6 Oct  5 19:02 .node-version -&amp;gt; .nvmrc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You’ve successfully symlinked &lt;code class=&quot;highlighter-rouge&quot;&gt;.node-version&lt;/code&gt; to point to &lt;code class=&quot;highlighter-rouge&quot;&gt;.nvmrc&lt;/code&gt;!&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Don’t rely on the aliases that &lt;code class=&quot;highlighter-rouge&quot;&gt;nvm&lt;/code&gt; supports!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Updating this file takes a minute! Testing those changes will take more time, but that’s to be expected! It may just mean to run all the integration tests locally or on your CI server. In the long term - this will save your time, and probably your ass!&lt;/p&gt;

&lt;p&gt;The builds or environments are not reproducible. It may be OK for an evening project (but don’t forget about the psychopath who knows where you live!), but for production environment it’s absolutely not recommended! Something is going to fail when a trivial fix is being deployed.
You can pray that to be the build, because more subtle errors may creep into production! However, having a broken build when you want to deploy a business-critical fix/feature is no fun.&lt;/p&gt;

&lt;p&gt;Try answering this one question - would you produce a production build of your app without using a &lt;code class=&quot;highlighter-rouge&quot;&gt;yarn.lock&lt;/code&gt; or a &lt;code class=&quot;highlighter-rouge&quot;&gt;package.lock&lt;/code&gt; file? Yep, I thought so. :)&lt;/p&gt;

&lt;p&gt;I’ve personally had a similar issue with this blog. I may write a follow-up post on that some day! ;)&lt;/p&gt;
</description>
        <pubDate>Sat, 05 Oct 2019 00:00:00 +0300</pubDate>
        <link>http://www.creepingcoder.com/2019/10/05/using-nvm-and-nodenv-side-by-side/</link>
        <guid isPermaLink="true">http://www.creepingcoder.com/2019/10/05/using-nvm-and-nodenv-side-by-side/</guid>
      </item>
    
      <item>
        <title>Start using Prezto!</title>
        <description>&lt;p&gt;I was using &lt;a href=&quot;https://github.com/robbyrussell/oh-my-zsh&quot;&gt;oh-my-zsh&lt;/a&gt; for a really long time and I was pretty happy with it. However, lately I decided to look for an alternative, more specfically - a more performant one. And I stumbled upon &lt;a href=&quot;https://github.com/sorin-ionescu/prezto&quot;&gt;Prezto&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;getting-rid-of-oh-my-zsh&quot;&gt;Getting rid of oh-my-zsh&lt;/h2&gt;

&lt;p&gt;As I mentioned, I was using &lt;code class=&quot;highlighter-rouge&quot;&gt;oh-my-zsh&lt;/code&gt;, first thing we need to do is to get rid of it! This can be done pretty easily, you just execute the following shell script:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;uninstall_oh_my_zsh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will perform the uninstallation and will create backup of your current &lt;code class=&quot;highlighter-rouge&quot;&gt;.zshrc&lt;/code&gt; file in the home (&lt;code class=&quot;highlighter-rouge&quot;&gt;~&lt;/code&gt;) directory, the new file will be something like: &lt;code class=&quot;highlighter-rouge&quot;&gt;~/.zshrc.omz-uninstalled-2019-09-22_08-31-19&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;installing-prezto&quot;&gt;Installing Prezto&lt;/h2&gt;

&lt;p&gt;This is pretty easy, you can follow the &lt;a href=&quot;https://github.com/sorin-ionescu/prezto#instructions&quot;&gt;instructions&lt;/a&gt; in the &lt;strong&gt;GitHub&lt;/strong&gt; repo.&lt;/p&gt;

&lt;p&gt;If you’ve done everything correctly, you should have your &lt;code class=&quot;highlighter-rouge&quot;&gt;Prezto&lt;/code&gt; installed in &lt;code class=&quot;highlighter-rouge&quot;&gt;~/.preztorc&lt;/code&gt; directory.&lt;/p&gt;

&lt;h3 id=&quot;how-to-extend-path&quot;&gt;How to “extend” PATH?&lt;/h3&gt;

&lt;p&gt;You can add your custom directories to &lt;code class=&quot;highlighter-rouge&quot;&gt;PATH&lt;/code&gt; by editing the &lt;code class=&quot;highlighter-rouge&quot;&gt;zprofile&lt;/code&gt; file. &lt;a href=&quot;https://github.com/sorin-ionescu/prezto/blob/2873885d37e362ae9be8ff4cb93ae36739ac0067/runcoms/zprofile#L45&quot;&gt;Here&lt;/a&gt; is an example from the current latest source.&lt;/p&gt;

&lt;h3 id=&quot;enabling-vi-mode&quot;&gt;Enabling “vi” mode&lt;/h3&gt;

&lt;p&gt;If you a fan of &lt;code class=&quot;highlighter-rouge&quot;&gt;vi&lt;/code&gt;, you can enable this mode for your shell. If you haven’t tried it before - I think you should… I am struggling myself to learn some of the most basic &lt;code class=&quot;highlighter-rouge&quot;&gt;vi&lt;/code&gt; usage (may have another blog post on that).&lt;/p&gt;

&lt;p&gt;Edit the &lt;a href=&quot;https://github.com/sorin-ionescu/prezto/blob/2873885d37e362ae9be8ff4cb93ae36739ac0067/runcoms/zpreztorc#L60&quot;&gt;following line&lt;/a&gt;, change &lt;code class=&quot;highlighter-rouge&quot;&gt;emacs&lt;/code&gt; to &lt;code class=&quot;highlighter-rouge&quot;&gt;vi&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;clipboard&quot;&gt;Clipboard&lt;/h4&gt;

&lt;p&gt;If you want to have your &lt;code class=&quot;highlighter-rouge&quot;&gt;vi&lt;/code&gt; clipboard to work with the system one, you need a plugin. &lt;a href=&quot;https://github.com/belak/prezto-contrib&quot;&gt;contrib-clipboard&lt;/a&gt; is the one that I use. Again, follow the &lt;a href=&quot;https://github.com/belak/prezto-contrib#usage&quot;&gt;instructions&lt;/a&gt;. After that, you need to list the &lt;code class=&quot;highlighter-rouge&quot;&gt;contrib-clipboard&lt;/code&gt; in &lt;a href=&quot;https://github.com/sorin-ionescu/prezto/blob/2873885d37e362ae9be8ff4cb93ae36739ac0067/runcoms/zpreztorc#L29&quot;&gt;zpreztorc&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;slow-input&quot;&gt;Slow input&lt;/h4&gt;

&lt;p&gt;Add &lt;code class=&quot;highlighter-rouge&quot;&gt;KEYTIMEOUT=1&lt;/code&gt; to your &lt;code class=&quot;highlighter-rouge&quot;&gt;~/.zshrc&lt;/code&gt; to eliminate the &lt;code class=&quot;highlighter-rouge&quot;&gt;ESC&lt;/code&gt; delay.&lt;/p&gt;

&lt;h3 id=&quot;changing-your-theme&quot;&gt;Changing your theme&lt;/h3&gt;

&lt;p&gt;Just take a look at the author’s &lt;a href=&quot;https://github.com/sorin-ionescu/prezto#themes&quot;&gt;instructions&lt;/a&gt;.
Personally, I use &lt;code class=&quot;highlighter-rouge&quot;&gt;powerlevel10k&lt;/code&gt;, it has a nice wizard, where you choose the whatever looks best to you! Also, it auto-installs the needed fonts!&lt;/p&gt;

&lt;h2 id=&quot;set-your-nodejs-environment&quot;&gt;Set your NodeJS environment&lt;/h2&gt;

&lt;h3 id=&quot;add-nodenv&quot;&gt;Add nodenv&lt;/h3&gt;

&lt;p&gt;Don’t use &lt;a href=&quot;https://github.com/nvm-sh/nvm&quot;&gt;NVM&lt;/a&gt;. It’s sooo slow, one of the reasons I started looking for an alternative to &lt;code class=&quot;highlighter-rouge&quot;&gt;oh-my-zsh&lt;/code&gt;. A quick &lt;a href=&quot;https://github.com/nodenv/nodenv/wiki/Why-nodenv%3F&quot;&gt;FAQ&lt;/a&gt; why you should choose &lt;code class=&quot;highlighter-rouge&quot;&gt;nodenv&lt;/code&gt;. It’s worth the time (2min read, probably).&lt;/p&gt;

&lt;p&gt;It works instantaneously, something which can’t be said for &lt;code class=&quot;highlighter-rouge&quot;&gt;NVM&lt;/code&gt;. Just search for “nvm slow” and you’ll know what I am talking about.&lt;/p&gt;

&lt;h4 id=&quot;installation&quot;&gt;Installation&lt;/h4&gt;

&lt;p&gt;You should use &lt;code class=&quot;highlighter-rouge&quot;&gt;homebrew&lt;/code&gt; if you are using &lt;code class=&quot;highlighter-rouge&quot;&gt;MacOS&lt;/code&gt;. Just execute the following:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;brew &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;nodenv
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Please note that there is a single &lt;code class=&quot;highlighter-rouge&quot;&gt;e&lt;/code&gt; in &lt;code class=&quot;highlighter-rouge&quot;&gt;nodenv&lt;/code&gt;, this tripped me while setting up my shell. There is a &lt;code class=&quot;highlighter-rouge&quot;&gt;nodeenv&lt;/code&gt; formulae as well…&lt;/p&gt;

&lt;p&gt;Of course, if you are a developer, you know &lt;code class=&quot;highlighter-rouge&quot;&gt;copy&lt;/code&gt;/&lt;code class=&quot;highlighter-rouge&quot;&gt;paste&lt;/code&gt; is always the way to go. ;)&lt;/p&gt;

&lt;p&gt;More &lt;a href=&quot;https://github.com/nodenv/nodenv#homebrew-on-macos&quot;&gt;detailed&lt;/a&gt; instructions you can find in the &lt;strong&gt;GitHub&lt;/strong&gt; repo.&lt;/p&gt;

&lt;h4 id=&quot;setting-up-prezto&quot;&gt;Setting up Prezto&lt;/h4&gt;

&lt;p&gt;Add the following line: &lt;code class=&quot;highlighter-rouge&quot;&gt;eval &quot;$(nodenv init -)&quot;&lt;/code&gt; in your &lt;code class=&quot;highlighter-rouge&quot;&gt;~/.zshrc&lt;/code&gt; after sourcing &lt;code class=&quot;highlighter-rouge&quot;&gt;Prezto&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;but-it-doesnt-work-with-nvmrc&quot;&gt;But it doesn’t work with .nvmrc&lt;/h4&gt;

&lt;p&gt;Yeah, that’s the drawback. There is a &lt;a href=&quot;https://github.com/ouchxp/nodenv-nvmrc&quot;&gt;nodenv-nvmrc&lt;/a&gt; fork that does just that. I don’t recommend it though. Auto-changing versions between builds is not something I want, especially in a production environment.&lt;/p&gt;

&lt;p&gt;Just lock down your &lt;code class=&quot;highlighter-rouge&quot;&gt;NodeJS&lt;/code&gt; version using a &lt;code class=&quot;highlighter-rouge&quot;&gt;.node-version&lt;/code&gt; file!&lt;/p&gt;

&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;zsh-prezto.png&quot; alt=&quot;Prezto shell&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After a week, I am really happy with my new setup. I forced myself to learn something new and now I am struggling every day in the terminal, because I am using &lt;code class=&quot;highlighter-rouge&quot;&gt;vi&lt;/code&gt; mode.
Also, this post was written entirely in &lt;code class=&quot;highlighter-rouge&quot;&gt;vi&lt;/code&gt;, took a little bit longer than anticipated, but hey, I may start to love it. ;)&lt;/p&gt;

&lt;h2 id=&quot;other-resource&quot;&gt;Other resource&lt;/h2&gt;

&lt;p&gt;Make sure to check these awesome blog posts:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://joshsymonds.com/blog/2014/06/12/shell-awesomeness-with-prezto/&quot;&gt;Shell Awesomeness With Prezto&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://wikimatze.de/better-zsh-with-prezto/&quot;&gt;Better ZSH with Prezto&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sat, 28 Sep 2019 00:00:00 +0300</pubDate>
        <link>http://www.creepingcoder.com/2019/09/28/start-using-prezto/</link>
        <guid isPermaLink="true">http://www.creepingcoder.com/2019/09/28/start-using-prezto/</guid>
      </item>
    
      <item>
        <title>Absolute imports in create-react-app</title>
        <description>&lt;p&gt;Don’t you hate when you need to import a module, but you need to import 2 directories up? Or was it 3?!&lt;/p&gt;

&lt;p&gt;I think everyone’s felt the pain if he has written any &lt;strong&gt;React&lt;/strong&gt; code. :)&lt;/p&gt;

&lt;h2 id=&quot;what-is-a-relative-import&quot;&gt;What is a relative import?&lt;/h2&gt;

&lt;p&gt;Here is a sample code which imports a &lt;strong&gt;Redux&lt;/strong&gt; action creator:&lt;/p&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;removeUser&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;../../../actions/removeUser&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This hurts the most when you move a component or create a new one which needs to import something which is waaay up in the project’s structure…&lt;/p&gt;

&lt;h2 id=&quot;what-is-an-absolute-import&quot;&gt;What is an absolute import?&lt;/h2&gt;

&lt;p&gt;Now that we’ve seen what’s a &lt;em&gt;relative&lt;/em&gt; import, we can show what’s an &lt;em&gt;absolute&lt;/em&gt; import.&lt;/p&gt;

&lt;p&gt;Here it is:&lt;/p&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;removeUser&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;actions/removeUser&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Way better, huh?&lt;/p&gt;

&lt;p&gt;I don’t know about you, but I really don’t want to specify all the &lt;code class=&quot;highlighter-rouge&quot;&gt;../../..&lt;/code&gt; paths. Also, it’s ugly!&lt;/p&gt;

&lt;h2 id=&quot;okay-but-how&quot;&gt;Okay, but how?&lt;/h2&gt;

&lt;p&gt;Well, it documented in the &lt;a href=&quot;https://create-react-app.dev/docs/importing-a-component#absolute-imports&quot;&gt;create-react-app docs&lt;/a&gt;, which are pretty good actually!&lt;/p&gt;

&lt;p&gt;You need to create a &lt;code class=&quot;highlighter-rouge&quot;&gt;jsconfig.json&lt;/code&gt; file at the root of your project, NOT the &lt;code class=&quot;highlighter-rouge&quot;&gt;src&lt;/code&gt; directory, with the following content:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;compilerOptions&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;baseUrl&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;src&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;include&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;src&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;exclude&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;node_modules&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I’ve added the exclusion of &lt;code class=&quot;highlighter-rouge&quot;&gt;node_modules&lt;/code&gt;. Not sure why was this needed, but I experienced some issues when it was not present. Maybe I’ll write a follow-up post later on that topic some day.&lt;/p&gt;

&lt;h2 id=&quot;is-that-all&quot;&gt;Is that all?&lt;/h2&gt;

&lt;p&gt;Well, this works great if everything you need to import is located under &lt;code class=&quot;highlighter-rouge&quot;&gt;src/&lt;/code&gt; directory, but what if I have a &lt;code class=&quot;highlighter-rouge&quot;&gt;tests&lt;/code&gt; directory with all the test helper functions you need, which is at the same level with the &lt;code class=&quot;highlighter-rouge&quot;&gt;src&lt;/code&gt; directory? Well, you’re out of luck… :(&lt;/p&gt;

&lt;p&gt;Or at least you were! Now (some 9-10 months ago…) the following &lt;a href=&quot;https://github.com/facebook/create-react-app/pull/6055&quot;&gt;pull request&lt;/a&gt; was merged! The most notable thing added is the support to override &lt;code class=&quot;highlighter-rouge&quot;&gt;moduleNameMapper&lt;/code&gt; for &lt;code class=&quot;highlighter-rouge&quot;&gt;jest&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;What this means is we can map our &lt;code class=&quot;highlighter-rouge&quot;&gt;tests&lt;/code&gt; modules the way we want! Here is what I do in my &lt;code class=&quot;highlighter-rouge&quot;&gt;package.json&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nl&quot;&gt;&quot;jest&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;moduleNameMapper&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;tests/(.*)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;rootDir&amp;gt;/tests/$1&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now if we import &lt;code class=&quot;highlighter-rouge&quot;&gt;tests/constants&lt;/code&gt; in our tests we’re going to get the proper modules resolved, no need to specify a relative path anymore!&lt;/p&gt;

&lt;h2 id=&quot;but-vs-code-cant-navigate-to-my-jsx-components&quot;&gt;But VS Code can’t navigate to my JSX components?!&lt;/h2&gt;

&lt;p&gt;Well… yeah. There is an &lt;a href=&quot;https://github.com/microsoft/vscode/issues/30290&quot;&gt;issue&lt;/a&gt;, you just need to add the following line under &lt;code class=&quot;highlighter-rouge&quot;&gt;compilerOptions&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nl&quot;&gt;&quot;jsx&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;react&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;NOTE:&lt;/em&gt; This was taken from the following &lt;a href=&quot;https://github.com/microsoft/vscode/issues/30290#issuecomment-328711049&quot;&gt;response&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;final-result&quot;&gt;Final result&lt;/h2&gt;

&lt;p&gt;Here is the final result, ready for copy/paste, in all its glory:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;compilerOptions&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;baseUrl&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;src&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;jsx&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;react&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;include&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;src&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;exclude&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;node_modules&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;That’s it! I find this very useful and I am pretty sure it boosts my productivity.&lt;/p&gt;

&lt;p&gt;Writing the &lt;em&gt;absolute&lt;/em&gt; imports may give you an insight if you’ve structured your project badly as well!&lt;/p&gt;

&lt;p&gt;Until next time! ;)&lt;/p&gt;
</description>
        <pubDate>Sun, 22 Sep 2019 00:00:00 +0300</pubDate>
        <link>http://www.creepingcoder.com/2019/09/22/absolute-imports-in-cra/</link>
        <guid isPermaLink="true">http://www.creepingcoder.com/2019/09/22/absolute-imports-in-cra/</guid>
      </item>
    
      <item>
        <title>What is an &quot;incoming change&quot; in VS Code?</title>
        <description>&lt;p&gt;This is a post mostly for myself. Einstein said that you truly understand something if you can describe it to a 7-years old.&lt;/p&gt;

&lt;p&gt;So, this is my attempt to explain something to myself in a blog post. :))&lt;/p&gt;

&lt;h2 id=&quot;the-problem&quot;&gt;The “problem”?&lt;/h2&gt;

&lt;p&gt;Here’s what I often wonder is which is the &lt;code class=&quot;highlighter-rouge&quot;&gt;incoming&lt;/code&gt; and which is the &lt;code class=&quot;highlighter-rouge&quot;&gt;current&lt;/code&gt; change. Of course, you are thinking it’s very obvious then you’re probably right. But hey, some of us are not that quick thinking… apparently. ;)&lt;/p&gt;

&lt;h2 id=&quot;my-development-workflow&quot;&gt;My development workflow&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Create a &lt;code class=&quot;highlighter-rouge&quot;&gt;feature&lt;/code&gt; branch from &lt;code class=&quot;highlighter-rouge&quot;&gt;master&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Add some stuff there.&lt;/li&gt;
  &lt;li&gt;Rebase &lt;code class=&quot;highlighter-rouge&quot;&gt;feature&lt;/code&gt; on top of &lt;code class=&quot;highlighter-rouge&quot;&gt;master&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Open a pull (merge) request.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;when-the-lighting-strikes&quot;&gt;When the lighting strikes&lt;/h2&gt;

&lt;p&gt;If there are no conflicts between &lt;code class=&quot;highlighter-rouge&quot;&gt;feature&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;master&lt;/code&gt; step 3 “just happens”. However, if there are, you see the following dialog in &lt;strong&gt;VS Code&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;vs-code-merge-conflict.png&quot; alt=&quot;VS Code merge conflict&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I’ve annotated what is coming from &lt;code class=&quot;highlighter-rouge&quot;&gt;master&lt;/code&gt; and what is from the &lt;code class=&quot;highlighter-rouge&quot;&gt;feature&lt;/code&gt; branch. To understand why the current change is from &lt;code class=&quot;highlighter-rouge&quot;&gt;master&lt;/code&gt; should be obvious if you know how &lt;code class=&quot;highlighter-rouge&quot;&gt;rebase&lt;/code&gt; works in &lt;code class=&quot;highlighter-rouge&quot;&gt;git&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;how-does-rebase-work&quot;&gt;How does rebase work?&lt;/h2&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;rebase&lt;/code&gt; gets the branch name you’ve given and then replays all of your commits on top of them. In our case, this means &lt;code class=&quot;highlighter-rouge&quot;&gt;master&lt;/code&gt; is the &lt;code class=&quot;highlighter-rouge&quot;&gt;current&lt;/code&gt; and while every change that is applied is an &lt;code class=&quot;highlighter-rouge&quot;&gt;incoming&lt;/code&gt; one.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;That’s it! Now I’ve explained this to myself, hopefully I won’t be thinking this every time I need to resolve a conflict in &lt;strong&gt;VS Code&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Please note, if you are using &lt;code class=&quot;highlighter-rouge&quot;&gt;merge&lt;/code&gt; to integrate &lt;code class=&quot;highlighter-rouge&quot;&gt;master&lt;/code&gt; to your &lt;code class=&quot;highlighter-rouge&quot;&gt;feature&lt;/code&gt; branch the “roles” are reversed! But hey, don’t do that, make the reviewers’ life easier! ;)&lt;/p&gt;
</description>
        <pubDate>Sat, 21 Sep 2019 00:00:00 +0300</pubDate>
        <link>http://www.creepingcoder.com/2019/09/21/incoming-change-in-vscode/</link>
        <guid isPermaLink="true">http://www.creepingcoder.com/2019/09/21/incoming-change-in-vscode/</guid>
      </item>
    
      <item>
        <title>What is &quot;describe&quot; useful for?</title>
        <description>&lt;p&gt;I thought I knew what &lt;a href=&quot;https://jestjs.io/docs/en/api#describename-fn&quot;&gt;describe&lt;/a&gt; was for. But as almost everything under-used, I didn’t really knew what I could REALLY do with it. ;)&lt;/p&gt;

&lt;p&gt;It proved itself more useful than I thought. Besides grouping of tests - the thing I’ve used it before (which can be really cool and useful, too!), it has one great use-case - it gives you the ability to run &lt;code class=&quot;highlighter-rouge&quot;&gt;beforeAll&lt;/code&gt;/&lt;code class=&quot;highlighter-rouge&quot;&gt;afterAll&lt;/code&gt; (or &lt;code class=&quot;highlighter-rouge&quot;&gt;beforeEach&lt;/code&gt;/&lt;code class=&quot;highlighter-rouge&quot;&gt;afterEach&lt;/code&gt;) setup “hooks” (too much &lt;a href=&quot;https://reactjs.org/docs/hooks-intro.html&quot;&gt;React Hooks&lt;/a&gt;?!) per &lt;code class=&quot;highlighter-rouge&quot;&gt;describe&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;This is really helpful when you have a more complex test scenarios. Like setting up some mocks to validate the &lt;code class=&quot;highlighter-rouge&quot;&gt;success&lt;/code&gt; and the &lt;code class=&quot;highlighter-rouge&quot;&gt;error&lt;/code&gt; paths. You can setup the appropriate mock depending on what you want to test.&lt;/p&gt;

&lt;p&gt;Here is a quick code sample:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;afterAll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// restore the default mock after all tests&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;setupMock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;beforeAll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;setupMock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;OK&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;should succeed of course ;)&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// write your magical code here!&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;beforeAll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;setupMock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ERROR&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;expect only errors here... :(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// the &quot;bad&quot; code goes here...&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I’m not suggesting this is the only valid use-case of &lt;code class=&quot;highlighter-rouge&quot;&gt;describe&lt;/code&gt;, but it was something I actually needed in my job. ;)&lt;/p&gt;

&lt;p&gt;Think twice before using those “hooks” (&lt;code class=&quot;highlighter-rouge&quot;&gt;beforeAll&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;afterAll&lt;/code&gt;), they can be easily overused.&lt;/p&gt;
</description>
        <pubDate>Mon, 12 Aug 2019 00:00:00 +0300</pubDate>
        <link>http://www.creepingcoder.com/2019/08/12/what-is-describe-useful-for/</link>
        <guid isPermaLink="true">http://www.creepingcoder.com/2019/08/12/what-is-describe-useful-for/</guid>
      </item>
    
  </channel>
</rss>
