Day 05 Testing & Deploy

Testing and Deployment

Vitest unit tests, Vue Test Utils, component testing, and deploying a Vue app to Vercel or Netlify with environment variables and a CI pipeline that catches regressions.

~1 hour Intermediate Hands-on Precision AI Academy

Today's Objective

Vitest unit tests, Vue Test Utils, component testing, and deploying a Vue app to Vercel or Netlify with environment variables and a CI pipeline that catches regressions.

01

The Production Build

During development, Vite serves your source files directly. For production, it bundles and minifies everything into optimized static files. Run the build command and inspect what it produces.

Terminal
npm run build

# Output:
# dist/
#   index.html
#   assets/
#     index-abc123.js    ← all your JavaScript, minified
#     index-def456.css   ← all your CSS

# Preview the production build locally before deploying
npm run preview

The dist/ folder is what you deploy. It's just static files — no server needed. That's what makes Vue apps cheap and fast to host.

02

Environment Variables

Never hardcode API keys or environment-specific URLs in your code. Use Vite's environment variable system.

.env (development)
# Vite only exposes vars that start with VITE_
VITE_API_URL=http://localhost:3000
VITE_APP_TITLE=My App Dev
.env.production
VITE_API_URL=https://api.myapp.com
VITE_APP_TITLE=My App
Using in your code
// Access with import.meta.env
const apiUrl = import.meta.env.VITE_API_URL
const isDev = import.meta.env.DEV
const isProd = import.meta.env.PROD

// Use in API calls
const res = await fetch(`${import.meta.env.VITE_API_URL}/users`)
💡
Add .env.local to your .gitignore. This file holds your real secrets and never gets committed. The .env file (with non-secret defaults) can be committed safely.
03

Deploying to Netlify

netlify.toml
[build]
  command = "npm run build"
  publish = "dist"

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200
  # This redirect is REQUIRED for Vue Router history mode
  # Without it, refreshing on /about returns a 404

Push your code to GitHub, then connect the repo in Netlify. Set your environment variables in Netlify's dashboard (Site Settings → Environment Variables). Netlify auto-deploys every time you push to main.

04

Deploying to Vercel

Terminal (Vercel CLI)
npm i -g vercel
vercel login
vercel  # follow the prompts

# Or connect GitHub repo at vercel.com for auto-deploys
vercel.json
{
  "rewrites": [
    { "source": "/(.*)", "destination": "/index.html" }
  ]
}
ℹ️
Both Netlify and Vercel offer free tiers that are more than enough for personal projects. Vercel has slightly better performance on their CDN. Netlify has more generous build minutes on the free tier. Either works great for Vue.
05

GitHub Actions: Auto-Deploy on Push

.github/workflows/deploy.yml
name: Deploy to Netlify

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm run build
      - uses: netlify/actions/cli@master
        with:
          args: deploy --dir=dist --prod
        env:
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
📝 Day 5 Exercise
Deploy Your Vue App Live
  1. Take the task list app from Day 1 (or any component you've built this week) and make it production-ready.
  2. Add at least one environment variable for your app title or API URL.
  3. Run npm run build and inspect the dist/ folder.
  4. Run npm run preview and verify everything works on the production build.
  5. Push to GitHub and deploy to either Netlify or Vercel.
  6. Share the live URL. You just shipped a Vue app.

Day 5 Summary

Course Complete

Completing all five days means having a solid working knowledge of Vue.js in 5 Days. The skills here translate directly to real projects. The next step is practice — pick a project and build something with what was learned.

Day 5 Checkpoint

Before moving on, verify you can answer these without looking:

  • What is the core concept introduced in this lesson, and why does it matter?
  • What are the two or three most common mistakes practitioners make with this topic?
  • Can you explain the key code pattern from this lesson to a colleague in plain language?
  • What would break first if you skipped the safeguards or best practices described here?
  • How does today's topic connect to what comes in Day the final lesson?

Live Bootcamp

Learn this in person — 2 days, 5 cities

Thu–Fri sessions in Denver, Los Angeles, New York, Chicago, and Dallas. $1,490 per seat. June–October 2026.

Reserve Your Seat →
Back to Course
Vue.js in 5 Days — Full Course Overview