<?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: Ola Johansson</title>
    <description>The latest articles on DEV Community by Ola Johansson (@olaj).</description>
    <link>https://dev.to/olaj</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%2F888408%2F6ed987b9-338d-4421-84c4-8a3ae9368b0a.png</url>
      <title>DEV Community: Ola Johansson</title>
      <link>https://dev.to/olaj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/olaj"/>
    <language>en</language>
    <item>
      <title>My Tuples in C# note to self</title>
      <dc:creator>Ola Johansson</dc:creator>
      <pubDate>Thu, 29 Jun 2023 11:51:45 +0000</pubDate>
      <link>https://dev.to/olaj/my-tuples-in-c-note-to-self-46dc</link>
      <guid>https://dev.to/olaj/my-tuples-in-c-note-to-self-46dc</guid>
      <description>&lt;p&gt;Everytime i just temporary need to send some data from one method to another i'm running into the issue, "I don't want to create a class just for this, can't just send some anonymous method of some sort".&lt;/p&gt;

&lt;p&gt;And each time I'm struggling with Tuples. The worst thing is that it's so hard to search for "where i used it before" since it doesn't really have name to search for.&lt;/p&gt;

&lt;p&gt;And that is why i'm writing this now.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;myListOfTuple&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SomeTable&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UserId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AnotherNumber&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AsEnumerable&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;UserId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UserId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;AnotherNumber&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AnotherNumber&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nf"&gt;DoStuff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myListOfTuple&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;DoStuff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;(&lt;/span&gt;&lt;span class="n"&gt;Guid&lt;/span&gt; &lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;Points&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;SecurityLevel&lt;/span&gt;&lt;span class="p"&gt;)&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;myTupleList&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;things&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myTupleList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Number&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UserId&lt;/span&gt; &lt;span class="p"&gt;!=&lt;/span&gt; &lt;span class="m"&gt;1234&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>csharp</category>
    </item>
    <item>
      <title>IncludeMembers in AutoMapper for mapping relations</title>
      <dc:creator>Ola Johansson</dc:creator>
      <pubDate>Wed, 22 Mar 2023 10:11:20 +0000</pubDate>
      <link>https://dev.to/olaj/includemembers-in-automapper-for-mapping-relations-2jo3</link>
      <guid>https://dev.to/olaj/includemembers-in-automapper-for-mapping-relations-2jo3</guid>
      <description>&lt;p&gt;Sometimes you need to grab a value from a relations table, as in this case the sortorder of the specific relation between a "list" and an "item".&lt;/p&gt;

&lt;p&gt;Using Automapper i have always had issues with this and usually just been lazy and mapped the other properties manually or used the AfterMap feature.&lt;/p&gt;

&lt;p&gt;But today i found out about the IncludeMembers method. It's super simple and you just include the inner property and automapper will treat it just like it's "merged" with the actual source.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;CreateMap&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ListItemRelation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ItemForCustomList&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;
   &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;IncludeMembers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ForMember&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dest&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;dest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SortOrder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Sortorder&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>automapper</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Git Setup</title>
      <dc:creator>Ola Johansson</dc:creator>
      <pubDate>Wed, 22 Feb 2023 07:35:20 +0000</pubDate>
      <link>https://dev.to/olaj/git-aliases-i-use-37ci</link>
      <guid>https://dev.to/olaj/git-aliases-i-use-37ci</guid>
      <description>&lt;p&gt;Just a list of git commands i use.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git config --global alias.ac '!git add -A &amp;amp;&amp;amp; git commit -m'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git config --global core.editor "code --wait"&lt;/code&gt;&lt;/p&gt;

</description>
      <category>git</category>
    </item>
    <item>
      <title>Deep copy object in JS / ES6</title>
      <dc:creator>Ola Johansson</dc:creator>
      <pubDate>Thu, 29 Dec 2022 09:45:08 +0000</pubDate>
      <link>https://dev.to/olaj/deep-copy-object-in-js-es6-47c3</link>
      <guid>https://dev.to/olaj/deep-copy-object-in-js-es6-47c3</guid>
      <description>&lt;p&gt;This is a thing I'm running into pretty often. In a test or whatnot i want clean data for each test. I usually just use the spread syntax.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mockEvent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{...&lt;/span&gt;&lt;span class="nx"&gt;testData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;events&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;defaultEventRegularSite&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the problem with this is that it actually just do a shallow copy. If you want to get a totally clean object this wont work if the object has more nested properties.&lt;/p&gt;

&lt;p&gt;If you want a deep copy, you can use JSON like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mockEvent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;testData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;events&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;defaultEventRegularSite&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reference: &lt;a href="https://stackoverflow.com/questions/38416020/deep-copy-in-es6-using-the-spread-syntax" rel="noopener noreferrer"&gt;Stack Overflow&lt;/a&gt;&lt;/p&gt;

</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>Deploy a storybook via Azure Devops to Azure Static Web App</title>
      <dc:creator>Ola Johansson</dc:creator>
      <pubDate>Tue, 11 Oct 2022 07:27:42 +0000</pubDate>
      <link>https://dev.to/olaj/deploy-a-storybook-via-azure-devops-to-azure-static-web-app-139g</link>
      <guid>https://dev.to/olaj/deploy-a-storybook-via-azure-devops-to-azure-static-web-app-139g</guid>
      <description>&lt;p&gt;I've spent the morning trying to deploy my static storybook to a Azure Static Web App. I've found a few blog posts about it but they seemed a bit outdated.&lt;/p&gt;

&lt;p&gt;Finally i figured out that you could just do everything with the &lt;a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-static-web-app-v0?view=azure-pipelines"&gt;AzureStaticWebApp&lt;/a&gt; pipeline task.&lt;/p&gt;

&lt;p&gt;For me it worked to just add this command to a pipeline.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;task&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AzureStaticWebApp@0&lt;/span&gt;
  &lt;span class="na"&gt;inputs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app_build_command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;yarn&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;build-storybook'&lt;/span&gt;
    &lt;span class="na"&gt;output_location&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/storybook-static'&lt;/span&gt;
    &lt;span class="na"&gt;skip_app_build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;
    &lt;span class="na"&gt;is_static_export&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;azure_static_web_apps_api_token&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;$(deployment-token)'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will need to add a $(deployment-token) variable that you will find on your static web app in Azure, but otherwise that was all i needed, no need to run any custom yarn commands and so on.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Test dynamic class names from CSS Modules in Cypress</title>
      <dc:creator>Ola Johansson</dc:creator>
      <pubDate>Fri, 23 Sep 2022 08:11:29 +0000</pubDate>
      <link>https://dev.to/olaj/test-dynamic-class-names-from-css-modules-in-cypress-pml</link>
      <guid>https://dev.to/olaj/test-dynamic-class-names-from-css-modules-in-cypress-pml</guid>
      <description>&lt;p&gt;Sometimes you want to test that a element in your code get the correct CSS class. I use CSS Modules so it's impossible to know the exact class name when you writing the test.&lt;/p&gt;

&lt;p&gt;Sometimes i have worked around this issue by asserting directly against the actual css i.e&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findByText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/my text/gi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;should&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;have.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;background-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rgb(60, 99, 132)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;should&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;have.attr&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;href&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;and&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;include&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;about&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works, but usually it's not really the color your after but if for example a element is active or focused or something.&lt;/p&gt;

&lt;p&gt;And today i did some digging and finally found how to do this. Really simple tbh.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findByText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/my text/gi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;attr&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;class&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;should&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;contain&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;selected&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findByText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/my text/gi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;should&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;have.attr&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;href&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;and&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;include&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;about&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that i use &lt;a href="https://testing-library.com/docs/cypress-testing-library/intro/"&gt;Testing Library for Cypress&lt;/a&gt; to get that "findByText" method. But this should also work for regular cypress "cy.get" commands.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://github.com/cypress-io/cypress/issues/1212#issuecomment-403351091"&gt;Github Issue Comment&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>cypress</category>
      <category>testing</category>
    </item>
    <item>
      <title>Import and @use from absolute paths in Next.JS</title>
      <dc:creator>Ola Johansson</dc:creator>
      <pubDate>Fri, 16 Sep 2022 07:54:53 +0000</pubDate>
      <link>https://dev.to/olaj/import-and-use-from-absolute-paths-in-nextjs-e1m</link>
      <guid>https://dev.to/olaj/import-and-use-from-absolute-paths-in-nextjs-e1m</guid>
      <description>&lt;p&gt;I have ignored my relative paths imports in JS and for my Sass / Scss stuff for years. Today i finally decided to take a look and see how this could be solved.&lt;/p&gt;

&lt;h3&gt;
  
  
  Node / Typescript
&lt;/h3&gt;

&lt;p&gt;So instead of having imports like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;colors&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../../css/colors.module.scss&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;colors&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../css/colors.module.scss&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;that are really hard to copy-paste and also looks pretty ugly we can have this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;colors&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@/css/colors.module.scss&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;no matter where i am in the project. To fix this all you need is to add this to your tsconfig.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;compilerOptions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;baseUrl&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@/css/*&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;css/*&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reference: &lt;a href="https://nextjs.org/docs/advanced-features/module-path-aliases"&gt;Next.JS Documentation&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  For Scss @use / @import
&lt;/h3&gt;

&lt;p&gt;And the same thing for Sass, all you have to add is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;moduleExports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;sassOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;includePaths&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;css/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then you can go from&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="k"&gt;@use&lt;/span&gt; &lt;span class="s2"&gt;"../../css/colors.module.scss"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="k"&gt;@use&lt;/span&gt; &lt;span class="s2"&gt;"colors.module.scss"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Sass version works a bit different since there you just add a "global path". It will always look in the "same path" first but then it will look in the global.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://stackoverflow.com/questions/35937477/how-to-use-absolute-path-to-import-custom-scss-when-using-react-webpack"&gt;Stack Overflow&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Issues with :hover, visibility and clicks in Cypress</title>
      <dc:creator>Ola Johansson</dc:creator>
      <pubDate>Tue, 30 Aug 2022 06:56:22 +0000</pubDate>
      <link>https://dev.to/olaj/issues-with-hover-visibility-and-clicks-in-cypress-55il</link>
      <guid>https://dev.to/olaj/issues-with-hover-visibility-and-clicks-in-cypress-55il</guid>
      <description>&lt;p&gt;I had some issues with my tests this morning and ever since I've started to use Cypress i have had various issues with hover states and clicks.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sometimes it works to just use &lt;code&gt;click({force: true})&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Sometimes it works to use &lt;code&gt;.trigger("show")&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;And sometimes none of these works.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm not 100% sure why it works or doesn't work but in this case i think it had to do with me using "visibility" instead of "display" in my CSS and that i had a transition that had some delay on showing the element that i wanted to click.&lt;/p&gt;

&lt;p&gt;I have used this great &lt;a href="https://github.com/dmtrKovalenko/cypress-real-events"&gt;cypress-real-events&lt;/a&gt; package before and it seems to have helped this time as well. This library adds a "realHover()" event that works with CSS.&lt;/p&gt;

&lt;p&gt;What finally worked for me in this case was this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;      &lt;span class="nx"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;should work to report spam&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;visit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/software/arch-linux/about/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;intercept&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://hooks.slack.com/services/**&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="p"&gt;},&lt;/span&gt;
          &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hej&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;post-to-slack&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;window:confirm&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findByTestId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;app-comment-89111&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
          &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;realHover&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// Seems i need this&lt;/span&gt;
          &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;within&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findByTestId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;report-spam&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
              &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;realHover&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// AND this, not sure why.&lt;/span&gt;
              &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;should&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;have.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;visibility&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;visible&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// without this my transitions seems to mess and caused flakyness to the test.&lt;/span&gt;
              &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;click&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
          &lt;span class="p"&gt;});&lt;/span&gt;

        &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@post-to-slack&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As usual with my post these are mainly notes to myself, this blog post really help me this time so if you want more &lt;a href="https://filiphric.com/hover-in-cypress"&gt;details go here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>cypress</category>
      <category>testing</category>
    </item>
    <item>
      <title>Trying to parse "accept-language" header, beware of extra spaces</title>
      <dc:creator>Ola Johansson</dc:creator>
      <pubDate>Wed, 24 Aug 2022 06:41:51 +0000</pubDate>
      <link>https://dev.to/olaj/trying-to-parse-accept-language-header-beware-of-extra-spaces-17h2</link>
      <guid>https://dev.to/olaj/trying-to-parse-accept-language-header-beware-of-extra-spaces-17h2</guid>
      <description>&lt;p&gt;For some reason i've decided to parse this header myself the other day, shouldn't be that hard i supposed. And it wasn't that hard and everything was working perfectly locally.&lt;/p&gt;

&lt;p&gt;Then i deployed this to my prod and things started to act weird. Only one language was detected and so forth. Finally i noticed that in prod my header string looked like this.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"sv, fr; q=0.9, en; q=0.8, no; q=0.7"&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;and locally it looked like this&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"sv,fr;q=0.9,en;q=0.8,no;q=0.7"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I'm not sure why and I'm not sure what is more correct. But i just needed to add some trim to my parsing method and now things works.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Match a CSS Class in Cypress</title>
      <dc:creator>Ola Johansson</dc:creator>
      <pubDate>Wed, 24 Aug 2022 06:32:00 +0000</pubDate>
      <link>https://dev.to/olaj/match-a-css-class-in-cypress-4dhe</link>
      <guid>https://dev.to/olaj/match-a-css-class-in-cypress-4dhe</guid>
      <description>&lt;p&gt;Another "note to self" post. Sometimes it's really hard to figure out how to assert stuff in various JS testing frameworks. Today i just wanted to check if a certain element had a CSS Class, and since i use CSS Modules i can't use "have.class" because i need to match the name. So according to &lt;a href="https://docs.cypress.io/api/commands/should#Assert-class-name-contains-heading"&gt;Cypress documentation&lt;/a&gt; this is how you do it. Note that I'm also using Cypress Testing Library, i.e. the "findByText" part of this code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;        &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findByText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/english/i&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;should&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;$s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$s&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;have&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
          &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
          &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/LanguageList_highlighted/gi&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tbh it feels a bit complicated and it would of course be nice if you could just do something like &lt;code&gt;cy.findByText(/english/i).should("match.class", /LanguageList_highlighted/gi)&lt;/code&gt;. If anyone know a simpler way of doing this, let me know.&lt;/p&gt;

</description>
      <category>cypress</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>testing</category>
    </item>
    <item>
      <title>Make your self-signed certificate trusted by Chrome (and Firefox)</title>
      <dc:creator>Ola Johansson</dc:creator>
      <pubDate>Wed, 17 Aug 2022 12:56:59 +0000</pubDate>
      <link>https://dev.to/olaj/make-your-self-signed-certificate-trusted-by-chrome-and-firefox-4m02</link>
      <guid>https://dev.to/olaj/make-your-self-signed-certificate-trusted-by-chrome-and-firefox-4m02</guid>
      <description>&lt;p&gt;These instructions are for Windows and works for me™ in Chrome.&lt;/p&gt;

&lt;h4&gt;
  
  
  Create a self-signed certificate with a DnsName
&lt;/h4&gt;

&lt;p&gt;Create a new certificate with powershell &lt;/p&gt;

&lt;p&gt;&lt;code&gt;New-SelfSignedCertificate -DnsName localhost -CertStoreLocation cert:\LocalMachine\My&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The DnsName is important and if you use a custom domain via a host file you should add the domain you use there.&lt;/p&gt;

&lt;h4&gt;
  
  
  Make sure you use this certificate on your localhost
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RUAmmgyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/coe21k2dxm5itihlme28.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RUAmmgyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/coe21k2dxm5itihlme28.png" alt="Picture of setting your certificate for your host in IIS" width="644" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Export the certificate from Chrome
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Go to your localhost website and open up the inspector&lt;/li&gt;
&lt;li&gt;Under the security tab, click the "View Certificate" button.&lt;/li&gt;
&lt;li&gt;Go to the details tab in the dialog and click "Copy to file"&lt;/li&gt;
&lt;li&gt;Follow the wizard and choose the Cryptographic Message Syntax Standard - PKCS #7 (i do not think the "Include all checkbox" is important)&lt;/li&gt;
&lt;li&gt;Save it somewhere.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Import the certificate to the "Trusted Root Certification Authorites"
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt; Go to Chrome Settings&lt;/li&gt;
&lt;li&gt; Click advanced at the bottom&lt;/li&gt;
&lt;li&gt; Click the Manage Certificates link to open the certificate dialog&lt;/li&gt;
&lt;li&gt; Click import&lt;/li&gt;
&lt;li&gt; Follow the wizard and pick your exorted certificate file&lt;/li&gt;
&lt;li&gt; Click browse and choose "Trusted Root Certification Authorites"&lt;/li&gt;
&lt;li&gt; Done!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After this you should restart Chrome and you should not get any warnings.&lt;/p&gt;

&lt;p&gt;All this information was collected at various places in this Stack Overflow question: &lt;a href="https://stackoverflow.com/questions/7580508/getting-chrome-to-accept-self-signed-localhost-certificate"&gt;https://stackoverflow.com/questions/7580508/getting-chrome-to-accept-self-signed-localhost-certificate&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Bonus - Make it work in Firefox as well
&lt;/h3&gt;

&lt;p&gt;Apparently Firefox doesn't use the global windows store for certificates. But it's easy to fix.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  In Firefox, type 'about:config' in the address bar&lt;/li&gt;
&lt;li&gt;  If prompted, accept any warnings&lt;/li&gt;
&lt;li&gt;  Right-click to create a new boolean value, and enter 'security.enterprise_roots.enabled' as the Name&lt;/li&gt;
&lt;li&gt;  Set the value to 'true'&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Credits to &lt;a href="https://support.umbrella.com/hc/en-us/articles/115000669728-Configuring-Firefox-to-use-the-Windows-Certificate-Store"&gt;this post&lt;/a&gt; for this info.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Notes about Cloudflare cache and json</title>
      <dc:creator>Ola Johansson</dc:creator>
      <pubDate>Mon, 18 Jul 2022 07:43:43 +0000</pubDate>
      <link>https://dev.to/olaj/notes-about-cloudflare-cache-and-json-21ke</link>
      <guid>https://dev.to/olaj/notes-about-cloudflare-cache-and-json-21ke</guid>
      <description>&lt;p&gt;I have spent a lot of time trying to understand how to setup cache for json and API requests in Cloudflare lately and finally i have made some progress. This is not a step by step guide but mostly a "notes to self" post so i can make some more sense of it all.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If workers are active on a route page rules are ignored. Took me a while to realize this.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloudflare only execute ONE page rule per request, so make sure the rules are in the correct order and you don't have any "catch all" rule at the top.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also note that the above note is not applied to workers route, with workers the routes is matched by how detailed they are. I.e domain.com/test is used even if domain.com/* exist and the order doesn't matter.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After you know this it should simply be to set a custom page rule on the path you want to cache with the option&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Cache Level: Cache Everything&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
