Category: JavaScript

JavaScript React Testing

JavaScript testing #16. Snapshot testing with React, Jest, and Vitest

This entry is part 16 of 18 in the JavaScript testing tutorial

Unit testing is handy for testing how our React components behave when the user interacts with them. However, this might not be enough. Besides testing the logic behind a particular component, we should also test if our user interface changes unexpectedly. We can use snapshot testing to detect unintended modifications to how our components render. Introduction to […]

JavaScript NestJS

API with NestJS #148. Understanding the injection scopes

This entry is part 148 of 168 in the API with NestJS

When a NestJS application starts, it creates instances of various classes, such as controllers and services. By default, NestJS treats those classes as singletons, where a particular class has only one instance. NestJS then shares the single instance of each provider across the entire application’s lifetime, creating a singleton provider scope. If you want to […]

JavaScript

Comparing ECMAScript Modules and CommonJS

JavaScript started as a simple language used to make static websites more dynamic and interactive. However, projects written in JavaScript began getting increasingly complex a long time ago. Because of that, it quickly became apparent that we needed a way to break the code into smaller, manageable pieces. Throughout the years, people have had many […]

JavaScript

Monorepos with Yarn Workspaces

With monorepos, we keep the code for different projects together in one big repository. This makes sharing and reusing the code across multiple projects easier and can simplify dependency management. Each project has its own directory, scripts, and dependencies. We can use Yarn workspaces designed with monorepos in mind to handle all that. In this […]

JavaScript

Understanding native JavaScript modules

It’s been a long time since the JavaScript projects began to grow in complexity. Because of that, breaking the code into manageable pieces became essential. In the history of JavaScript development, we went through many different approaches to splitting our code into modules. Good examples include solutions such as CommonJS, which is used in NodeJS. […]

React

React with Vite and TypeScript and its common challenges

For a long time, the Create React App environment was the most popular way of starting new React projects. It does not seem to be maintained anymore, and the new React documentation does not even mention it. Fortunately, there are alternatives. The documentation mentions solutions such as Next.js. While it is a good solution, it […]

JavaScript Node.js

Introduction to managing a private NPM registry with Verdaccio

An organization often develops more than one project. Since the projects are often part of a more extensive ecosystem, this could lead to duplicating some of the code. To deal with this problem, we can create JavaScript libraries that we can reuse across various projects. The most straightforward way of maintaining packages available in all […]

JavaScript NestJS

API with NestJS #113. Logging with Prisma

This entry is part 113 of 168 in the API with NestJS

Using a debugger with an application running locally on our machine is a great way to troubleshoot. Unfortunately, we can’t do that with a deployed app. To be able to investigate any potential issues, we need to implement a logging functionality. In this article, we use the logger built into NestJS and integrate it with […]

JavaScript NestJS

API with NestJS #112. Serializing the response with Prisma

This entry is part 112 of 168 in the API with NestJS

When fetching data from the database, we do not always want to present it to the user in the original form. When working with NestJS, the most popular way of modifying the response is with the library. However, using the above library with Prisma requires a bit of work. In this article, we provide […]