1. COURSE NAME : MERN STACK WEB
DEVELOPMENT (MSWD)
COURSE CODE: 22SDCS01R
TOPIC: INTRODUCTION TO VALIDATION
FACULTY NAME : Y AMARAIAH
1
2. FEATURES OF VALIDATION
• Testing is a crucial aspect of software development in the MERN (MongoDB,
Express.js, React, Node.js) stack, It helps ensure that data is accurate,
consistent, and secureBefore executing the program lets verify the code properly
displaying the cpntent
• Client side validation,server side validation,data validation,form
validation,custom validation for fixing and handling the error handling
• It ensures to make security and integrity as well as accuracy….
2
3. FEATURES OF VALIDATION
• key features and considerations for testing in the MERN stack
• Backend (Node.js/Express): Use testing frameworks like Mocha, Jest, or
Jasmine to write unit tests for individual functions and modules.
• Frontend (React): Utilize Jest along with tools like Enzyme or React Testing
Library for unit testing React components.
• Real tie validation,custom validation,localized validation message
• Custom Error Handling Middleware
• Authentication and Authorization.
3
4. MODULES
• A set of functions you want to include in your application.
• Forntend :React testing
• Test framework just,test
• Utitilities: React framework LIBRARY,
• Data base testing :mongodb memory server.
Declarative schema validation.
• Support for complex validation rules.
• Integration with Hapi.js and other frameworks.
4
5. REQUIRE()
5
Install Dependencies:
First, install the necessary dependencies using npm:
bash
Copy code
npm init -y
npm install mocha chai
Create a Simple Function:
function add(a, b) { return a + b; } module.exports = add;
Write a Test:
Tests.program
Configure and Run the test
6. MODULE
Node.js typically involves various modules and tools to cover different aspects of
testing
1 mocha :rich testing module
2 chai : like mocha It provides a wide range of assertion styles, allowing developers
to choose the one that fits their preference.
3 Supertest: Description: Supertest is an HTTP assertion library often used in
combination with Mocha to test Express.js applications by making HTTP
requests and asserting the responses.
4 jest,enjyne,sinon,mocking and mongo db modules are using
6
7. STREAMS AND FILES
• validation practices across different layers of your MERN stack application, you can enhance the
security, reliability, and integrity
• streams and files is a common requirement, especially when handling file uploads, processing large
datasets, or managing file storage.
• Stream in node js
• Express.js
• React frontend
• Mongodb for data storing
• var fs = require('fs’);
where fs file stream
7