Unit Test and Integration Test for AWS Lambda/NodeJS in TypeScript

Unit Test and Integration Test for AWS Lambda/NodeJS in TypeScript

Unit Test and Integration Test for AWS Lambda/NodeJS in TypeScript. We are going to use jest to manage all the tests. In order to use jest with TypeScript, we will have to install some babel dependencies. We talked about how to apply TypeScript to a AWS SAM CLI created NodeJS project, check the link below.

AWS Lambda/NodeJS (TypeScript) Series

  1. How to Use TypeScript for AWS Lambda in 3 Steps
  2. Unit Test and Integration Test for AWS Lambda/NodeJS in TypeScript

Preparation

We are going to use jest to manage all the tests. In order to use jest with TypeScript, we will have to install some babel dependencies. Please check the installation commands below:

// install jest and types
$ npm i -D jest @types/jest

// install babel support to use jest with typescript
$ npm i -D babel-jest @babel/core @babel/preset-env @babel/preset-typescript

We install them in dev-dependencies because they are only used during testing, not in the final built package. After installation, we need to create the babel.config.js in the to make babel work. File content:

module.exports = {
    presets: [
        ['@babel/preset-env', {targets: {node: 'current'}}],
        '@babel/preset-typescript',
    ],
};

aws-lambda aws jest typescript javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Webpack 5 Builds for AWS Lambda Functions with TypeScript

Today’s post will be a short overview that bridges these together: it shows how I bundled the TypeScript code from the Twitter post with node modules and prepare it for deployment. Webpack 5 Builds for AWS Lambda Functions with TypeScript

Adding Code to AWS Lambda, Lambda Layers, and Lambda Extensions Using Docker

Adding Code to AWS Lambda, Lambda Layers, and Lambda Extensions Using Docker. With Docker, we have three ways to add code to Lambda that isn’t directly part of our Lambda function. Try to AWS Lambda, Lambda Layers, and Lambda Extensions Using Docker.

Deploy a Typescript Lambda Function with AWS CDK and a Deno Layer

Learn how to deploy a Deno layer with AWS CDK and TypeScript. A Lambda function. Lambda layer that enables Deno runtime. A TypeScript Program.

Invoke AWS Lambda with Another Lambda Function with Nodejs

In this article, I will show you how to invoke a lambda function from another lambda function.