No video

Unit Testing in Serverless - tutorial including DynamoDB

  Рет қаралды 15,865

Complete Coding - Master AWS Serverless

Complete Coding - Master AWS Serverless

4 жыл бұрын

In this video we'll learn about unit testing in Serverless and how we can also unit test interactions with AWS services such as DynamoDB
Code for starting this video:
github.com/SamWSoftware/Serve...
Code for completed Lesson
github.com/SamWSoftware/Serve...

Пікірлер: 33
@PeteWhelan
@PeteWhelan 4 жыл бұрын
Great video, thanks again Sam! Enjoyed this tutorial.
@CompleteCoding
@CompleteCoding 4 жыл бұрын
My pleasure!
@shwenansuwai2481
@shwenansuwai2481 4 жыл бұрын
Love your channel. Thank you for the lessons.
@CompleteCoding
@CompleteCoding 4 жыл бұрын
Glad you like them!
@flaviomovil
@flaviomovil 2 жыл бұрын
Thanks for this video Sam!! Was great! :) help me a lot!
@CompleteCoding
@CompleteCoding 2 жыл бұрын
Glad it helped you out
@0301311
@0301311 3 жыл бұрын
Testing for S3 is missing !
@CompleteCoding
@CompleteCoding 3 жыл бұрын
With S3 there isn't a library that I've found that works as well as this one does for dynamo. Since these are meant to be unit testing I would mock the s3 service to create the tests.
@JeanYvesP
@JeanYvesP 4 жыл бұрын
That is another great video!
@CompleteCoding
@CompleteCoding 4 жыл бұрын
Thanks! The next one on integration testing serverless Lambdas will be coming out shortly
@neosarchizo
@neosarchizo 4 жыл бұрын
Thanks for good video again!
@CompleteCoding
@CompleteCoding 4 жыл бұрын
My pleasure!
@2ederson
@2ederson 3 жыл бұрын
Hi! Quick question, using this same code or a similar one, If I wanted to use jest testing WITHOUT mocking the Database, using the real DynamoDB, does the configuration change or any additional changes to perform? I'm currently trying to make a change in the project, from having the DynamoDB configuration in Handler to a proper Dynamo.js file, but I seem to get the error: UnrecognizedClientException: The security token included in the request is invalid. I'm not sure if this stems from handler reading the dynamo configuration from serverless.yml, and the Dynamo.js file does not read it Any answer is appreciated.
@CompleteCoding
@CompleteCoding 3 жыл бұрын
You would have to change the configuration in Dynamo.js so that it uses the correct AWS credentials to access the real database when running a test. Add something like this to the top of the Dynamo.js file in the (isTest) block. This uses the credentials for the profile when running the lambda. var credentials = new AWS.SharedIniFileCredentials({profile: 'work-account'}); AWS.config.credentials = credentials;
@davidwalters76
@davidwalters76 3 жыл бұрын
basically all your vids 👍
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Thanks David. Glad they're helpful
@PeteWhelan
@PeteWhelan 4 жыл бұрын
Note to anyone using this tutorial having problems running Jest: Install Jest Globally AS WELL AS npm install --save-dev jest.
@CompleteCoding
@CompleteCoding 4 жыл бұрын
Nice spot Pete
@cristianecheverria3995
@cristianecheverria3995 4 жыл бұрын
Or instead of adding JEST Globally, you can add a script to package.json like "test": "jest" And then just run "npm run test"
@JorgeNunez22
@JorgeNunez22 3 жыл бұрын
Why Skipped the S3 unit tests???
@CompleteCoding
@CompleteCoding 3 жыл бұрын
With S3 there isn't a library that I've found that works as well as this one does for dynamo. Since these are meant to be unit testing I would mock the s3 service to create the tests.
@karthikr7038
@karthikr7038 3 жыл бұрын
I am getting error while executing jest with @shelf/jest-dynamodb added in jest.config.js file.
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Try following the previous video on serverless offline first. There may be some steps in that that are needed to get jest to work.
@karthikr7038
@karthikr7038 3 жыл бұрын
@@CompleteCoding java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
@rendelllasola66
@rendelllasola66 3 жыл бұрын
You can use jest-dynalite which is a fork of jest-dynamodb as replacement because it doesn't require Java.
@CompleteCoding
@CompleteCoding 3 жыл бұрын
@@rendelllasola66 Thanks for point that out
@shahidabbas2932
@shahidabbas2932 2 жыл бұрын
Hi, Sir i want to contact you .
@CompleteCoding
@CompleteCoding 2 жыл бұрын
My details are in the 'about' section of the channel page
@dhanwadc
@dhanwadc 4 жыл бұрын
First view
@CompleteCoding
@CompleteCoding 4 жыл бұрын
thanks Dhanwa
@adityanair3566
@adityanair3566 2 жыл бұрын
Dynamo intialisation file is written in TS. To compile ts file in jest, I read you need to include 'ts-jest' as preset. But to use dynamo local, we need to use "@shelf/jest-dynamodb" as preset. How can I add two presets in one jest config file? Please help me out. Great video btw!
@karthikr7038
@karthikr7038 3 жыл бұрын
java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
@CompleteCoding
@CompleteCoding 3 жыл бұрын
This sounds like you haven't got the Java processor required. If you follow this video on setting up serverless-offline it will show you how to install this. Then it should all work. kzfaq.info/get/bejne/q9KPa5iby7OUn6M.html
How to write Integration Tests for Serverless AWS Endpoints - API Gateway and Lambda Guide with Jest
33:04
Complete Coding - Master AWS Serverless
Рет қаралды 16 М.
Serverless Offline for testing on your local machine. Tutorial with DynamoDB
18:16
Complete Coding - Master AWS Serverless
Рет қаралды 35 М.
Why Is He Unhappy…?
00:26
Alan Chikin Chow
Рет қаралды 75 МЛН
ТЫ С ДРУГОМ В ДЕТСТВЕ😂#shorts
01:00
BATEK_OFFICIAL
Рет қаралды 6 МЛН
Serverless Framework with AWS Lambda Crash Course
1:29:11
Laith Academy
Рет қаралды 110 М.
AWS CDK testing with TypeScript and Jest - full course
42:17
Concise Developer
Рет қаралды 2,4 М.
Create a Serverless Database - DynamoDB with the Serverless Framework
9:59
Complete Coding - Master AWS Serverless
Рет қаралды 18 М.
Serverless Computing in 100 Seconds
16:46
Fireship
Рет қаралды 281 М.
Testing Serverless Functions with Jest & Next.js API Routes
20:30
Unit-testing your AWS Lambda functions in Go
45:37
Serverless Land
Рет қаралды 6 М.
Build a Harry Potter API with Node.js, Express.js, and Dynamo DB
32:01
JavaScript Unit Testing Tutorial for Beginners
48:32
Programming with Mosh
Рет қаралды 63 М.
Mocking Asynchronous Functions with Jest
21:50
Swashbuckling with Code
Рет қаралды 68 М.