MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Production Bundling, Testing & Deployment0%
Study Materials
JavaScript for AdvancedProgress 0%
1.1Higher-Order Functions & Currying1.2Function Composition & Pipelining1.3Memoization & Pure Functions1.4Execution Context & Call Stack Deep Dive1.5Scope Chain & Lexical Environment
18.1Architecture & State Store Design (Store Pattern)18.2Real-Time Collaborative Dashboard Engine18.3Offline-First Sync with IndexedDB & Service Worker18.4Production Bundling, Testing & Deployment
HomeTutorialsJavaScript for AdvancedProduction Bundling, Testing & Deployment

Production Bundling, Testing & Deployment

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study Materials

Building a world-class JavaScript application culminates in deploying it reliably to global production infrastructure. In this final capstone tutorial, you will master the end-to-end production workflow: automated unit testing (Vitest), bundle optimization (Vite/Rollup), CI/CD pipelines, and zero-downtime deployment.


1. Automated Testing Pyramid

1 ┌───────────────┐
2 │ E2E Tests │ (Playwright / Cypress: User flows across real browser)
3 └───────┬───────┘
4 │
5 ┌───────▼───────┐
6 │ Integration │ (Component mounting, API mock integration)
7 └───────┬───────┘
8 │
9 ┌───────▼───────┐
10 │ Unit Tests │ (Vitest / Jest: Fast, pure function verification)
11 └───────────────┘

2. Writing Production Unit Tests with Vitest

1import { describe, it, expect, beforeEach, vi } from 'vitest';
2import { Store } from './Store.js';
3import { appReducer } from './appReducer.js';
4 
5describe('Central Store Architecture', () => {
6 let store;
7 
8 beforeEach(() => {
9 store = new Store(appReducer, { count: 0, theme: 'light' });
10 });
11 
12 it('should initialize with provided initial state', () => {
13 expect(store.getState()).toEqual({ count: 0, theme: 'light' });
14 });
15 
16 it('should update state immutably when an action is dispatched', () => {
17 store.dispatch({ type: 'INCREMENT' });
18 expect(store.getState().count).toBe(1);
19 });
20 
21 it('should notify subscribers when state updates', () => {
22 const subscriberMock = vi.fn();
23 store.subscribe(subscriberMock);
24 
25 store.dispatch({ type: 'INCREMENT' });
26 
27 expect(subscriberMock).toHaveBeenCalledTimes(1);
28 expect(subscriberMock).toHaveBeenCalledWith(expect.objectContaining({ count: 1 }));
29 });
30 
31 it('should throw an error when mutating state directly', () => {
32 expect(() => {
33 store.getState().count = 99;
34 }).toThrow();
35 });
36});

3. Production Bundler Configuration (vite.config.js)

A production bundler configuration enforces code splitting, minification, and asset compression:

1import { defineConfig } from 'vite';
2import { visualizer } from 'rollup-plugin-visualizer';
3 
4export default defineConfig({
5 build: {
6 target: 'es2022', // Emit modern, compact ES2022 output
7 minify: 'terser', // High-performance minification
8 sourcemap: 'hidden', // Generates sourcemaps without public comments for Sentry
9 rollupOptions: {
10 output: {
11 // Manual Chunk Splitting
12 manualChunks: {
13 vendor: ['react', 'react-dom'],
14 charts: ['chart.js']
15 }
16 },
17 plugins: [
18 visualizer({ open: false, filename: 'bundle-analysis.html' })
19 ]
20 }
21 }
22});

4. GitHub Actions CI/CD Pipeline (.github/workflows/deploy.yml)

Automate testing, linting, building, and deployment on every git push:

1name: Production CI/CD Pipeline
2 
3on:
4 push:
5 branches: [ main ]
6 
7jobs:
8 verify-and-deploy:
9 runs-on: ubuntu-latest
10 
11 steps:
12 - name: Checkout Code
13 uses: actions/checkout@v4
14 
15 - name: Setup Node.js
16 uses: actions/setup-node@v4
17 with:
18 node-version: 20
19 cache: 'npm'
20 
21 - name: Install Dependencies
22 run: npm ci
23 
24 - name: Type Check
25 run: npx tsc --noEmit
26 
27 - name: Run Unit Tests
28 run: npm run test:run
29 
30 - name: Build Production Assets
31 run: npm run build
32 
33 - name: Deploy to Cloudflare Pages / Vercel
34 run: npx wrangler pages deploy dist --project-name=enterprise-app
35 env:
36 CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}

5. Production Release Checklist

Before promoting code to live production traffic:

  1. 1
    Zero TypeScript Errors: npx tsc --noEmit exits cleanly.
  2. 2
    100% Test Suite Passing: All unit and integration test assertions pass.
  3. 3
    Bundle Size Budgets Enforced: No initial chunk exceeds 150KB gzip.
  4. 4
    Security Headers Configured: Content Security Policy (CSP), HSTS, and X-Frame-Options enabled.
  5. 5
    Monitoring & Sentry Configured: Production release tagged with git commit hash.

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What command ensures a clean, deterministic install of dependencies based strictly on package-lock.json in CI/CD pipelines?
Question 2
What is the primary role of manual chunk splitting in a Rollup or Vite configuration?
Question 3
What is the difference between Unit Tests and End-to-End (E2E) Tests?
Question 4
Why is sourcemap: 'hidden' configured in production bundlers?
Question 5
What is the purpose of npm run test:run in CI/CD pipelines compared to standard test mode?

Related Lessons

Previous LessonNext Lesson
Offline-First Sync with IndexedDB & Service WorkerNone

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master JavaScript for Advanced with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
Previous
PreviousPrevNext