How mock modules while overriding specific methods in Jest

Suppose you have JS module that uses methods of another module when it’s gets transpiled. Here for example the MainModule uses SubModule method to set newNumber. Now to suppose you want to test addTwo function and mock SubModule also but override the subFunc method only. For this you can use jest.createMockFromModule(moduleName) along with jest.mock(moduleName).

Getting a remote PostgreSQL database backup via SSH tunnel

In this article I’m writing a way to retrieve a backup of a PostgreSQL database in a remote server when you have access to the server machine via SSH. This would come handy when you can’t directly connect to the database server from your local machine. For example, in a situation where the PostgreSQL server… Continue reading Getting a remote PostgreSQL database backup via SSH tunnel

To use 404 code or not

At work I’m working on implementing REST based API end-points to expand the functionaity of the front-end application. Recently I had a discussion with one of the developers in the team about what HTTP error should be used when something that is expected to be present is missing due to some inconsistency in the server.… Continue reading To use 404 code or not

Things to consider when upgrading Rails

Recently at work I had the opportunity to upgrade Rails from 4.2 all the way to Rails 6.1 for one of the core applications. With the experience, In this article I’m discussing some important points to consider when you are upgrading Rails.

An intro to Debugging

In this article I’ve gathered my thoughts to help developers to get better in debugging especially if they find debugging really hard. The article also lists a set of tools which will help them to debug efficiently and to improve their skills. Hopefully you will find some value in this article, if you are also… Continue reading An intro to Debugging