Posts

Showing posts with the label JS

Snapshot Testing with Jest

Image
Design Systems are pretty popular nowadays. As you company grows and has multiples apps/sites and products you new have a consistent experience across your brand. Having components is a great architectural pattern to help you to deliver the design system to code. However coding tests for a design system component can be very time consuming and super expensive.  IF you are using React, Jest is really your natural choice. Jest can let you do both Example based testing but also Snapshot testing. Snapshot testing can be amazing or complete waste really depends on what you use for. For Error messages snapshotting testing be super useful but for testing design system components is IMHO the killer use case. Jest has great tooling and make you life as an engineer, dealing with snapshots super easy and fun. So I made a video about Jest and React. Let's get started. 

Property-Based Testing with JSVerify

Image
Testing is important. Unit testing makes a lot of sense for Backend where we have business logic, however, for frontend, I would argue the value is not exactly the same. There is a concept called Property-Based Testing that comes from functional programming which is super useful. It makes the engineering life much easier and not only saves time typing but also makes your tests more robust with really not much more effort. So today I made a very short javascript / nodejs video talking about JSVerify . So Let's get started. Video Code https://github.com/diegopacheco/Diego-Pacheco-Sandbox/tree/master/scripts/node.js/jsverify-fun Cheers, Diego Pacheco

Building Redis-Modules with JavaScript using Cthulhu

Image
Cthulhu is an interesting project. It allows you to code custom redis-modules in JavaScript . This is very interesting because JS is very productive and easy to write code. You might be wondering how they made this efficient? Well, the secret is a project called Duktape which is an efficient JS engine written in C. So Cthulhu + Duktape will pre-compile your javascript function and run it on C which will be efficient and will be able to talk with redis core. Unfortunately, not all functions are available -- you can check the ones that are available here: List of available APIS . You can so a simple comparison with a module In C I wrote some time ago in this blog post . C is way more powerful but also way more error-prone and might take more time to write if you are not used to it. So for this Blog Post, I will how to download and compile Cthulhu and they install in Redis 4 and code some custom function in JavaScript. Let's get started.