Complete guide for debugging, testing, and verifying features across both the Next.js web app and iOS app.
- Read the relevant section below (Web or iOS)
- Run setup commands
- Start the dev environment
- Run a simple test to verify setup
- Make code changes
- Run relevant tests (see Quick Verification in BUG_VERIFICATION_WORKFLOW.md)
- Test manually with dev server or emulator
- Commit when all checks pass
# One-time setup
bun install
bun run dev # Start dev server at http://localhost:3000Start dev server:
- VS Code Task:
π οΈ DEBUG: Start Dev Server - Manual:
bun run dev - Access: http://localhost:3000
- Hot reload enabled
Features:
- Live code reloading on file changes
- Browser DevTools available
- Server logs in terminal
- TypeScript errors displayed in browser
The test server is required for running tests locally (provides API endpoints).
Start test environment:
VS Code Tasks in order:
1. Run: π οΈ DEBUG: Start Test Server (if not already running)
2. Run your test task
3. Run: π οΈ DEBUG: Stop Test Server (when done)Or use combined tasks (handles server start/stop automatically):
π§ͺ TEST: All Tests (with local server)- All testsπ§ͺ TEST: Demo Tests- User flow testsπ§ͺ TEST: API Tests- API logic testsπ TEST: Security Tests- Security validations
- Start dev server:
π οΈ DEBUG: Start Dev Server - Open http://localhost:3000 in browser
- Open DevTools (F12 or Cmd+Option+I)
- Check Console tab for errors
- Check Network tab for API issues
- Make code changes - page auto-reloads
# All tests in watch mode
bun run test
# Specific test file
bun run test tests/demo/login.test.ts
# Tests matching pattern
bun run test --grep "badge"
# Single run (no watch)
bun run test:runWhen a test fails:
- Read the error message - Vitest provides clear output
- Check test file - Understand what the test expects
- Run test in isolation:
bun run test tests/path/to/test.ts - Add debug output:
// In test file console.log('Debug:', someValue);
- Check live server - Run dev server and test manually
- Review test reports:
bun run test:summary # Show test failure summary
| Task | Command |
|---|---|
| Run all tests (watch) | π§ͺ TEST: All Tests |
| API tests only | π§ͺ TEST: API Tests |
| Demo tests only | π§ͺ TEST: Demo Tests |
| E2E tests | π§ͺ TEST: E2E Tests (Playwright) |
| Security tests | π TEST: Security Tests |
| Load tests | β‘ TEST: Load Tests |
# Type checking
bun run typecheck
# Linting
bun run lint
# Both (recommended before commit)
bun run test:ci- Start test server:
π οΈ DEBUG: Start Test Server - Run simulation:
π± SIM: Badge Simulationπ± SIM: Location Simulationπ± SIM: Posture Simulation
- Check results in logs
- Test related functionality with dev server
- Start dev server:
π οΈ DEBUG: Start Dev Server - Run:
π INTEGRATION: Webhooks Test - Check webhook test output
- Monitor server logs for webhook calls
- Start dev server with test server:
π οΈ DEBUG: Start Test Server - Test WebAuthn:
π INTEGRATION: WebAuthn Smoke Test - Manual test: Open http://localhost:3000/admin
- Check auth flows in console
Prerequisites:
- macOS with Xcode installed
- iOS 15.0+ or iPadOS 15.0+
- Device or simulator
Install dependencies:
cd ios
./setup.sh # One-time setupUsing Xcode (Recommended for debugging):
- Open
ios/EnterpriseShell.xcodeproj - Select target device/simulator
- Press Run (βR)
- Watch Xcode console for logs
Using command line:
cd ios
xcodebuild -scheme EnterpriseShell -configuration Debug -destination "platform=iOS Simulator,name=iPad Pro"Start iOS Simulator:
open -a SimulatorAvailable simulators:
- iPad Pro (15-inch)
- iPad Pro (11-inch)
- iPad Air
- iPad mini
- iPhone (various models)
Run app in simulator:
- Select iPad from Xcode scheme dropdown
- Press Run (βR)
- App launches in simulator
Set breakpoints:
- Click code line number in Xcode
- Run app (βR)
- Execution pauses at breakpoint
- Step over/into variables in debugger
View logs:
- Xcode Console (ββ§C)
- Device logs in Xcode organizer
Debug memory issues:
- Xcode Debug Navigator β Memory
- Instruments (βI) β Leaks, Zombies
Run unit tests:
cd ios
xcodebuild test -scheme EnterpriseShellTest categories:
- Session state machine tests
- Authentication flow tests
- Badge reader integration tests
- Keychain storage tests
- API integration tests
| Feature | How to Test |
|---|---|
| Badge Reading | Use simulator with mock hardware events |
| Session State | Navigate through app states, verify transitions |
| Authentication | Test Microsoft Entra ID login flow |
| Token Storage | Check Keychain via Xcode |
| App Launching | Select persona, verify correct app launches |
| Session Teardown | End session, verify data cleanup |
| Audit Logging | Check app logs for event entries |
| Problem | Solution |
|---|---|
| App won't build | Run ./setup.sh to install dependencies |
| Simulator won't start | Restart Simulator app, or reset content |
| Breakpoint not hit | Check build scheme and configuration |
| Memory leak suspected | Use Instruments β Leaks tool |
| Keychain access denied | Check entitlements in Xcode project |
-
Start web backend:
π οΈ DEBUG: Start Test Server
-
Run iOS app:
- Xcode: Press βR
- Or simulator with
xcodebuild test
-
Test authentication flow:
- iOS app logs in with badge/credentials
- Web backend receives authentication
- Session created successfully
-
Verify data sync:
- Change data in web app
- iOS app reflects changes
- Check audit logs
API Integration:
- Start test server:
π οΈ DEBUG: Start Test Server - iOS app makes API calls
- Check web server logs:
bun run test:server:start - Monitor API responses
Session Management:
- Start iOS app
- Start web dev server:
π οΈ DEBUG: Start Dev Server - View sessions dashboard at http://localhost:3000/admin
- Start/end iOS session, watch web console update
Audit Logging:
- Perform actions in iOS app
- Check web app audit log: http://localhost:3000/admin/audit
- Verify all actions logged
Run: π DEMO: Full Flow (with setup)
This runs:
- Starts test server
- Runs complete demo flow
- Stops test server
- Generates report
Run: π¬ DEMO: Executive Presentation
Quick feature showcase with key scenarios.
Run: β
DEMO: Validate Features
Validates all demo features work correctly.
- Run:
π¬ DEMO: Executive Presentation - Show web app in browser
- Start iOS app in simulator
- Walk through end-to-end scenarios
Use this to guide which tests to run for different types of changes:
| Change Type | Tests to Run |
|---|---|
| UI Change | Demo Tests, E2E Tests, Manual Testing |
| API Endpoint | API Tests, Integration Tests, Manual Testing |
| Authentication | Security Tests, Demo Tests, WebAuthn Test |
| Badge/Location | Simulation Tools, Demo Tests |
| Backend Logic | API Tests, Security Tests |
| iOS Feature | Xcode Unit Tests, Manual iOS Testing |
| Integration | All Integration Tests, Manual End-to-End |
| Security | Security Tests, Semgrep Analysis, Manual Review |
- Keep dev server running while developing
- Use browser DevTools to debug frontend
- Check server logs when API calls fail
- Run typecheck/lint before committing
- Start with quick tests during development
- Run full suite before submitting PR
- Focus on affected feature areas
- Review test output carefully
- Test on real device for badge reader features
- Use simulator for most development
- Check memory usage regularly
- Monitor performance in Instruments
- Use test server for consistent environment
- Check browser console AND server logs
- Run tests in isolation if confused
- Look at test failures carefully - they're informative
- Use load tests for new features (
β‘ TEST: Load Tests) - Profile with Xcode Instruments
- Monitor browser DevTools Network tab
- Check server response times in tests
- Read error message carefully
- Check test file to understand expectation
- Run test in isolation
- Check related server logs
- Review code changes you made
- Check browser console (F12)
- Check server logs
- Run unit tests to isolate issue
- Restart dev server if needed
- Clear browser cache if necessary
- Check Xcode console
- Review build errors carefully
- Run
./setup.shagain - Reset simulator if needed
- Check iOS code for crashes