dump static method
void
dump()
Dump current test state to console.
Prints:
- Backpack contents
- Current route
- Mocked APIs
- Time state
- Cache contents
- Files on faked disks
Implementation
static void dump() {
print('╔════════════════════════════════════════════════════════════════╗');
print('║ NyTest State Dump ║');
print('╠════════════════════════════════════════════════════════════════╣');
// Test mode
print('║ Test Mode: ${Nylo.isTestMode}');
// Current user
print('║ Acting As: ${_currentUser ?? 'Guest'}');
// Time
print('║ Time Frozen: ${NyTime.isFrozen}');
if (NyTime.isFrozen) {
print('║ Test Time: ${NyTime.now().toIso8601String()}');
}
// Backpack
print('╠════════════════════════════════════════════════════════════════╣');
print('║ Backpack Contents:');
// Can't easily enumerate Backpack, but we can check common keys
if (Nylo.isInitialized()) {
print('║ - nylo: initialized');
}
if (_currentUser != null) {
print('║ - auth_user: $_currentUser');
}
// Current route
print('╠════════════════════════════════════════════════════════════════╣');
print('║ Current Route: ${Nylo.getCurrentRouteName() ?? 'None'}');
// Route history
final List<dynamic> history = Nylo.getRouteHistory();
if (history.isNotEmpty) {
print('║ Route History:');
for (final route in history) {
print('║ - ${route['name']}');
}
}
// API mocks
print('╠════════════════════════════════════════════════════════════════╣');
print(
'║ API Mocks: ${NyMockApi.handlerCount} handlers, ${NyMockApi.patternCount} patterns',
);
// API call history
final List<ApiCallInfo> calls = NyMockApi.getCalls();
if (calls.isNotEmpty) {
print('║ API Call History:');
for (final call in calls) {
print('║ - ${call.method} ${call.endpoint}');
}
}
// Cache
final NyTestCache cache = NyTestCache.getInstance();
print('╠════════════════════════════════════════════════════════════════╣');
print('║ Cache: ${cache.count} entries');
if (cache.isNotEmpty) {
print('║ Cache Keys:');
for (final String key in cache.entries.keys) {
print('║ - $key');
}
}
// Disks
final Map<String, FakeDisk> fakes = FileStorage.fakes;
print('╠════════════════════════════════════════════════════════════════╣');
print('║ Faked Disks: ${fakes.length}');
for (final MapEntry<String, FakeDisk> entry in fakes.entries) {
final List<String> files = entry.value.memory.filesSync(
'',
recursive: true,
);
print('║ - ${entry.key}: ${files.length} files');
for (final String file in files.take(20)) {
print('║ $file');
}
if (files.length > 20) print('║ …and ${files.length - 20} more');
}
print('╚════════════════════════════════════════════════════════════════╝');
}