Mock window.location in unit tests

When you run unit tests (I am using Jestjs) on functions which read window.location.href or, you need to somehow mock the value. Problem is that when you try to edit the value of it will not work. Neither will work overriding it by Object.defineProperty(). But there is a simple workaround solution, and that […]

Sticky header menu with animation using Javascript

The problem I needed to create animated menu, which will stay always sticked to the top and will collapse or expand as user scroll How it should look Click the image for a live version – What do you need to implement it? You will need a little bit Javascript and CSS. There are several […]

My Bower/Gulp settings

This is my Gulp.js workflow settings based on examples shown in this PluralSight course (I really recommend you to watch it). I am using these gulp plugins: main-bower-files for creating list of js files to be injected gulp-inject for injecting js/css files into index.html file When you install some library via bower you should do so with the –save […]

Difference between async loops in C#

What do you think will happen when you run these 2 snippets of code? They both looks quite similar at the first sight, don’t they. This one var results = new List<SomeClass>(); mylist.ForEach(async item => { var result = await SomeDbQueryAsync(item); results.Add(result); }); versus this one var results = new List<SomeClass>(); foreach(var item in mylist) […]

VisualStudio has problem when multiple versions of Typescript are installed

You can have several versions of Typescript installed on your machine and each project in Visual Studio can be configured to use different version by specifying that version in .csproj file. Like this But you might still have problems with IntelliSense for some native javascript objects. VisualStudio uses file lib.d.ts  to learn interfaces of window objects, events, […]

Selenium WebDriver can’t start

After a few days of writing tests using Selenium, the WebDriver suddenly stopped working. It did not even start. I tried to restart my machine, check versions of Firefox and Selenium (both were up to date), restart Visual Studio, clean solution. Nothing worked.  There was not even an exception description. All I got was a […]

How to unit test Angular’s $resource and $http

Unit testing of Angular’s underlying $http can be very tricky. I’ve some spent considerable time to get the unit testing up and running. What was running OK in a live application, was not working at all in a unit test. I was getting error message “No pending request to flush !” all the time. My […]

Fyzika dopravní zácpy

Překlad článku The Physics Behind Traffic Jams od Williama Beaty. Poznámka překladatele: Nechávám vše v ich-formě. Takže pedem upozorňuji, že nežiju v Seattlu, a netrávím každý den 2 hodiny v zácpě, jako původní autor. Nicméně mi článek přišel natolik zajímavý, že ho tu překládám. Myslím, že pražáci mají s dopravou podobné zkušenosti jako lidi v […]