Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | 1x 1x | // Performance testing utilities for route prefetching
import { DASHBOARD_ROUTES, WALLET_ROUTES } from '@/constants/route';
export const performanceTestUtils = {
// Test if routes are being prefetched
testRoutePrefetching: () => {
console.group('๐งช Testing Route Prefetching');
// Check if prefetched components are in cache
const testRoutes = [
DASHBOARD_ROUTES.OVERVIEW,
WALLET_ROUTES.WALLET,
WALLET_ROUTES.TRANSACTIONS,
];
testRoutes.forEach(route => {
// This would normally check if the route is prefetched
// In a real test, you'd check the prefetched components map
console.log(`โ Testing prefetch for route: ${route}`);
});
console.groupEnd();
},
// Test loading performance
testLoadingPerformance: () => {
console.group('โก Testing Loading Performance');
const startTime = performance.now();
// Simulate a route change
setTimeout(() => {
const endTime = performance.now();
const duration = endTime - startTime;
console.log(`Route change simulation took: ${duration.toFixed(2)}ms`);
if (duration < 100) {
console.log('โ
Excellent performance');
} else if (duration < 300) {
console.log('โ
Good performance');
} else {
console.log('โ ๏ธ Performance could be improved');
}
}, 0);
console.groupEnd();
},
// Test service worker integration
testServiceWorkerIntegration: () => {
console.group('๐ง Testing Service Worker Integration');
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready
.then(registration => {
console.log('โ
Service Worker is registered and ready');
console.log('Scope:', registration.scope);
})
.catch(error => {
console.log('โ Service Worker not ready:', error);
});
} else {
console.log('โ Service Worker not supported');
}
console.groupEnd();
},
// Run all performance tests
runAllTests: () => {
console.log('๐ Running Performance Tests...');
performanceTestUtils.testRoutePrefetching();
performanceTestUtils.testLoadingPerformance();
performanceTestUtils.testServiceWorkerIntegration();
console.log('โ
All performance tests completed');
},
};
// Auto-run tests in development
Iif (process.env.NODE_ENV === 'development') {
// Run tests after app initialization
setTimeout(() => {
performanceTestUtils.runAllTests();
}, 2000);
}
|