5.0 KiB
Testing Auto-Updates
This guide explains how to test the auto-update system during development.
Quick Start
Option 1: Test with GitHub Releases (Easiest)
-
Set up dev-app-update.yml (already done):
provider: github owner: amiayweb repo: Hytale-F2P -
Lower your current version in
package.json:- Change version to something lower than what's on GitHub (e.g.,
2.0.1if GitHub has2.0.3)
- Change version to something lower than what's on GitHub (e.g.,
-
Run the app in dev mode:
npm run dev # or npm start -
The app will check for updates 3 seconds after startup
- If a newer version exists on GitHub, it will detect it
- Check the console logs for update messages
Option 2: Test with Local HTTP Server
For more control, you can set up a local server:
-
Create a test update server:
# Create a test directory mkdir -p test-updates cd test-updates -
Build a test version with a higher version number:
# In package.json, set version to 2.0.4 npm run build -
Copy the generated files to your test server:
- Copy
dist/latest.yml(orlatest-mac.ymlfor macOS) - Copy the built installer/package
- Copy
-
Start a simple HTTP server:
# Using Python python3 -m http.server 8080 # Or using Node.js http-server npx http-server -p 8080 -
Update dev-app-update.yml to point to local server:
provider: generic url: http://localhost:8080 -
Run the app and it will check your local server
Testing Steps
1. Prepare Test Environment
Current version: 2.0.3 (in package.json)
Test version: 2.0.4 (on GitHub or local server)
2. Run the App
npm run dev
3. Watch for Update Events
The app will automatically check for updates 3 seconds after startup. Watch the console for:
Checking for updates...
Update available: 2.0.4
4. Check Console Logs
Look for these messages:
Checking for updates...- Update check startedUpdate available: 2.0.4- New version foundDownload speed: ...- Download progressUpdate downloaded: 2.0.4- Download complete
5. Test UI Integration
The app sends these events to the renderer:
update-checkingupdate-available(with version info)update-download-progress(with progress data)update-downloaded(ready to install)
You can listen to these in your frontend code to show update notifications.
Manual Testing
Trigger Manual Update Check
You can also trigger a manual check via IPC:
// In renderer process
const result = await window.electronAPI.invoke('check-for-updates');
console.log(result);
Install Update
After an update is downloaded:
// In renderer process
await window.electronAPI.invoke('quit-and-install-update');
Testing Scenarios
Scenario 1: Update Available
- Set
package.jsonversion to2.0.1 - Ensure GitHub has version
2.0.3or higher - Run app → Should detect update
Scenario 2: Already Up to Date
- Set
package.jsonversion to2.0.3 - Ensure GitHub has version
2.0.3or lower - Run app → Should show "no update available"
Scenario 3: Prerelease Version
- Set
package.jsonversion to2.0.2b - Ensure GitHub has version
2.0.3 - Run app → Should detect update (prerelease < release)
Troubleshooting
Update Not Detected
- Check dev-app-update.yml exists in project root
- Verify dev mode is enabled - Check console for "Dev update mode enabled"
- Check version numbers - Remote version must be higher than current
- Check network - App needs internet to reach GitHub/local server
- Check logs - Look for error messages in console
Common Errors
- "Cannot find module 'electron-updater'": Run
npm install - "Update check failed": Check network connection or GitHub API access
- "No update available": Version comparison issue - check versions
Debug Mode
Enable more verbose logging by checking the console output. The logger will show:
- Update check requests
- Version comparisons
- Download progress
- Any errors
Testing with Real GitHub Releases
For the most realistic test:
-
Create a test release on GitHub:
- Build the app with version
2.0.4 - Create a GitHub release with tag
v2.0.4 - Upload the built files
- Build the app with version
-
Lower your local version:
- Set
package.jsonto2.0.3
- Set
-
Run the app:
- It will check GitHub and find
2.0.4 - Download and install the update
- It will check GitHub and find
Notes
- Dev mode only works when app is NOT packaged (
!app.isPackaged) - Production builds ignore
dev-app-update.ymland use the built-inapp-update.yml - macOS: Code signing is required for updates to work in production
- Windows: NSIS installer is required for auto-updates
Next Steps
Once testing is complete:
- Remove or comment out
forceDevUpdateConfigfor production - Ensure proper code signing for macOS
- Set up CI/CD to automatically publish releases