Dev Ramble

Guides, how-to's and other nonsensical ramblings from a software engineer

Home

How to Stub Methods to Return Different Values for Different Arguments with SinonJS

August 1, 2021

SinonJS is a popular testing framework for JavaScript. It allows us to easily spy, stub and mock our code. The following will be a quick how-to on stubbing JavaScript methods to return different values based on the provided arguments.

Continue Reading →

How to Use Cloud9 to Develop Python Lambda Functions

July 31, 2021

AWS Cloud9 is a powerful IDE you can use to develop code within your browser. It integrates with other AWS services like Lambda so you can easily download, modify and re-upload new versions of your Lambda function code. Cloud9 also comes with a managed EC2 instance with terminal access so you have full control of your development environment. In this blog post, I will run through an example of using Cloud9 to develop a Lambda function, including steps on adding a Python external package.

Continue Reading →

How to Schedule Lambda Functions in AWS Console

July 31, 2021

A common use case for AWS Lambda functions is to run them regularly on a schedule. This can be used in a wide range of scenarios, from periodically performing some web scraping to sending out regular updates using SNS. In this blog post, I’ll walk through the steps you need to take to start running your Lambda function on a schedule using only the AWS console.

Continue Reading →

Using Criteria Queries to Filter Entities With Many-To-Many Relationships

May 23, 2020

JPA Criteria Queries allow us to create complex queries in a object-oriented manner. In this post, I’ll provide an example where we create a query that filters an entity that has a many-to-many relationship with another entity.

Continue Reading →

Mocking setTimeout With Fake Timers Using Jest

May 16, 2020

Timer functions like setTimeout are commonly used in JavaScript to schedule tasks to run after some delay. When writing unit tests to test this kind of functionality, it isn’t ideal to wait for real time to pass especially if the delays are hours long. Jest allows us to use “fake timers” to instantly run timers to completion, or even advance time by a specified amount.

Continue Reading →

Using Manual Mocks for Imported Node Modules with Vue + Jest

May 10, 2020

Jest is a great test framework to use for unit testing Vue.js components. However mocking Node modules can be a bit tricky. In this blog post I’ll explain a method I’ve used in the past to mock an imported Node module like axios.

Continue Reading →