#7- Uesting for GET POST API using NOCK | Mocha Chai Unit Testing in TypeScript & Node Js

  Рет қаралды 1,428

Kumar Programming

Kumar Programming

Күн бұрын

►Kumar Programming - Keep Learning in a simple way
#7- GET POST API Testing using NOCK | Mocha Chai Unit Testing in TypeScript & Node Js
This is 7th video of this series, hope you are learning well. In this video we have covered how to test GET POST API mentods testing using AXIOS and
NOCK libarary to mock api and its data.
► Topics covered in this Series
1. Introduction -Unit Testing Mocha Chai - Done
2. Installation and Writing Test Suites and Test cases and Running Test cases (describe , it) - Done
3. Chai - Different Chai Assertion Styles (assert, expect, should) - Done
4. Common Chai Assertions - Done
5. Hooks (before, after, beforeEach, afterEach) - Done
6. Nested Test Suites- Done
7. Skipping and Focusing Tests (skip, only) - Done
8. Sinon (Spying, Mocking and Stubbing) - Done
9. Asynchronous Testing - (async await) - Done
10. Testing Promise - Done
11. Nock - Mock Api Calls and data - Done
12. GET POST Api Testing - Done
13. Code Coverage and Reporting (nyc-Istanbul)
► Used Framework and libraries
Mocha - Unit testing framework is the most popular framework for TypeScript/Javascript unit testing.
In this series, I used below popular libraries
Chai - for assertion with with multiple assertion style
Sinon - for spying , mocking and stubbing
AXIOS - GET/POST data from API
Nock - for async api mocking
Nyc - Unit test coverage report by nyc Istanbul and configurations
► Sample code on github:
github.com/kyp....
► Subscribe :
Subscribe Kumar Programming to watch more tutorials:
/ @kyprogramming
► JAVASCRIPT :
JavaScript - Interview Questions Answer Series - Introduction • JavaScript- Interview...
JavaScript - Interview Question - What is Difference between Map and WeakMap Object? • JavaScript - Interview...
JavaScript Interview Question - What is Design Pattern ? [ Singleton Factory & Observer ] • JavaScript Interview Q...
JavaScript Interview Question - What is Hoisting and Temporal Dead Zone (TDZ) ? • JavaScript Interview Q...
JavaScript Interview Question - What is Type Coercion ? • JavaScript Interview Q...
JavaScript Interview Question - What is difference between Spread and Rest Operator? • JavaScript Interview Q...
JavaScript Interview Question - What is difference between Shallow Copy and Deep Copy? • JavaScript Interview Q...
► FULL STACK DEVELOPER :
Full Stack Developer - Introduction - Road Map • Full Stack Developer ...
► UNIT TESTING - MOCHA CHAI :
#1- Introduction | Unit Testing | Mocha Chai in TypeScript Node • #1- Introduction | Un...
#2- Configuration and Installation | Unit Testing | Mocha Chai in TypeScript Node • #2- Configuration and ...
#3- Chai Assertion Style-(Should Expect Assert) | Common Chai Assertion | Mocha Chai TypeScript Node • #3- Chai Assertion Sty...
#4- Hooks | Nested Test Suite | Skip/Only | Mocha Chai Testing in TypeScript & Node • #4- Hooks | Nested Te...
#5- Syp Stub Mock using Sinon | Mocha Chai Unit Testing in TypeScript & Node Js • #5- Syp Stub Mock usin...
#6- Testing Asynchronous functions and Promise | Mocha Chai Unit Testing in TypeScript & Node Js • #6- Testing Asynchrono...
#7- Uesting for GET POST API using NOCK | Mocha Chai Unit Testing in TypeScript & Node Js • #7- Uesting for GET PO...
#8- Code coverage and Reporting using nyc tool | Mocha Chai Unit Testing in TypeScript & Node Js • #8- Code coverage and ...
► NODE JS - COMPLETE PROJECT :
Complete - Unit Testing -Mocha Chai in Node Typescript - 2 Hrs • Complete - Unit Testi...
Part 1 NodeJs Express TypeScript Mongo DB -Complete Project - Library Management - Step by Step • Part -1- NodeJs Expres...
Part 2 NodeJs Express TypeScript Mongo DB -Complete Project - Library Management - Step by Step • Part -2- NodeJs Expres...
Part 3 NodeJs Express TypeScript Mongo DB -Complete Project - Library Management - Step by Step • Part -3- NodeJs Expres...
Part 4 NodeJs Express TypeScript Mongo DB -Complete Project - Library Management - Step by Step • Part -4- NodeJs Expres...
Step by Step - Complete Project - NodeJs Express TypeScript Mongo DB Library Management - 05 Hrs • Step by Step - Comple...
► ANGULAR :
Angular Interview Questions - Difference between JIT and AOT Compiler • Angular Interview Ques...
Angular Interview Questions - Promise Vs Observable - With Practical Demo • Angular Interview Ques...
Angular Web Component Standalone - Single JavaScript File - Step By Step • Angular Web Component ...
Angular Interview Question - Unit Testing - Step by Step - Part 1 • Angular Interview Ques...
Angular Interview Question - Unit Testing - Part 2 • Angular Interview Ques...
Angular Interview Question - Unit Testing - Complete • Angular Interview Ques...
#Mocha #chai #UnitTesting #TypeScrriptUnitTesting #TSUnitTesting #typescript #typescripttutorial #JSUnitTesting #programming #coding #nodejs #nodejstutorial #kumarprogramming #kyprogramming #stepbystep #learning

Пікірлер: 7
@ashishkushwaha8773
@ashishkushwaha8773 7 ай бұрын
very well explained. keep it up
@kyprogramming
@kyprogramming 7 ай бұрын
Thank you Ashish for your comment. 👍
@bgovindnaren7405
@bgovindnaren7405 7 ай бұрын
One genuine doubt of mine... Isn't this same as saying a =0 b =0 and hence a =b? no offence fantastic video!
@kyprogramming
@kyprogramming 7 ай бұрын
Thank you Govind for your comment! If you are saying a=b it means you are assigning value of b to a. In order to check equality for a & b you should use == or === strict equality check operator like a === b or a == b. I hope I have answered for you query. Thanks.
@bgovindnaren7405
@bgovindnaren7405 7 ай бұрын
@@kyprogramming No sir... In the test we are only setting the value for the mocked response(let say for the response status is always gonna be 200 because we have returned the same in the main file) and in the expect(res.status) we saying that it should be equal to 200 So its always gonna pass the testcase if you only change the status from 200 to 404 in the expect statement then only it will fail. So in this analogy isn't this same as that of saying let a = 0. and b = 0( 0 is nothing but mocked response and the expected response in the expect statement) and saying a = b. In that sense I was asking the question. Pls clarify this doubt of mine.
@kyprogramming
@kyprogramming 7 ай бұрын
​@@bgovindnaren7405 ok, got your point. whenever we are trying to test any functions , we should mock other dependencies with the some mocked response (should not necesary have the actulal response )and same can we verify under assert. The whole idea is to test functionality for the relevent function under a single test cases not to the it's dependencies. Also its depends upon requirements and use cases what exactly we have to test. In this tutorial I have explained how we can utilize nock libraby in order to mock our actual API functionality for GET and POST. Hope I make it clear to you.
PyTest • REST API Integration Testing with Python
37:24
pixegami
Рет қаралды 85 М.
Ozoda - Lada (Official Music Video)
06:07
Ozoda
Рет қаралды 11 МЛН
iPhone or Chocolate??
00:16
Hungry FAM
Рет қаралды 38 МЛН
小丑妹妹插队被妈妈教训!#小丑#路飞#家庭#搞笑
00:12
家庭搞笑日记
Рет қаралды 37 МЛН
Express JS with TypeScript - Setup, Examples, Testing
1:20:13
Anson the Developer
Рет қаралды 32 М.
Angular Testing in 2023: Past, Present, and Future
26:21
Rainer Hahnekamp
Рет қаралды 12 М.
OpenAI’s New ChatGPT: 7 Incredible Capabilities!
6:27
Two Minute Papers
Рет қаралды 190 М.
Test-Driven Development // Fun TDD Introduction with JavaScript
12:55
How to do Performance Testing with k6
9:55
Alex Hyett
Рет қаралды 34 М.
Angular Unit Testing Crash Course - Make Your Project Bullet Proof
19:48
Monsterlessons Academy
Рет қаралды 15 М.
How to Check if a User Exists Among Billions! - 4 MUST Know Strategies
12:44
Ozoda - Lada (Official Music Video)
06:07
Ozoda
Рет қаралды 11 МЛН