Mocking same module ES6 dependencies

There is a subtle issue for which, unfortunately, neither ES6 nor proxyquire provide a solution. It is well described in this stackoverflow.com answer. So far in the previous articles of the series, the dependencies we were mocking were in a separate module from the code we were unit testing. But what if they were in the same module? more ...


Mocking ES6 module dependencies with proxyquire

In part one, I wrote about mocking ES6 module dependencies using the ES6 native import * from construct. It works mostly fine. However, you need to be aware of a potential issue:

  • You need to import modules to mock them, which means that those modules will be evaluated. That may be a problem if you don't want the code in this modules to be executed.

Another method I found to work well is using proxyquire.  It is one of many libraries aiming to streamline mocking dependencies to simplify unit testing. more ...


Mocking ES6 module dependencies with import * from

Not so long ago I faced a problem: I needed to mock ES6 module’s dependencies for unit testing. The reason for mocking dependencies in unit tests is the following: when I write a unit test, I want to test the functionality of a single unit of code, hence a unit test. However, if a module has any dependencies, those dependencies need be satisfied. That may mean importing and executing code in other modules. As a result, the unit test loses its purity – the test results will depend not only on the module I’m focusing on but also on the other code my module depends on. more ...



How to install CyanogenMod on Oneplus One

I really like my OnePlus One phone. It is an exemplary engineering achievement proving that it is possible to design a mobile phone as powerful as leading brand’s flagship models but costing half of their price.

Oneplus One is powered by Cyanogen OS, an open source OS based on Android Open Source Project (AOSP). Cyanogen OS has its own update cycles, which OnePlus One receives via over-the-air (OTA) updates. When I bought the phone, it had Cyanogen OS 11 installed, based on Android™ 4.4 KitKat. Pretty much when I turned on, it received update to Cyanogen OS 12, based on Android™ 5. The update went without a hitch, and the phone performed flawlessly for a few months… until the next update came through.

12.1-YOG4PAS1N0 is Cyanogen OS 12.1 based on Android™ 5.1.1. Unfortunately, once that update installed on my OnePlus One, it rendered the phone practically unusable. The problems included LTE connection dropping out, random freezes and reboots, application crashing, you name it… And after a couple weeks I had enough and decided to do something about that. So, I said goodbye to Cyanogen OS and hello to CyanogenMod Nightly Builds. more ...