Skip to content

Commit 90ab54a

Browse files
committed
chore: improve unit test report terminal output
1 parent f05fb28 commit 90ab54a

File tree

5 files changed

+37
-8
lines changed

5 files changed

+37
-8
lines changed

test-app/app/src/main/assets/app/test-es-module.mjs.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

test-app/app/src/main/assets/app/tests/testESModules.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@ function runESModuleTests() {
55
// Test 1: Load .mjs files as ES modules
66
console.log("\n--- Test 1: Loading .mjs files as ES modules ---");
77
try {
8-
var moduleExports = require("~/test-es-module.mjs");
8+
var moduleExports = require("~/testSimpleESModule.mjs");
99
if (moduleExports && moduleExports !== null) {
1010
console.log("Module exports:", JSON.stringify(moduleExports));
1111
passed++;
1212
} else {
1313
console.log("❌ FAIL: ES Module loaded but exports are null");
1414
failed++;
1515
}
16+
if (moduleExports.moduleType === "ES Module") {
17+
console.log(" - moduleType check passed");
18+
passed++;
19+
} else {
20+
console.log("❌ FAIL: moduleType check failed");
21+
failed++;
22+
}
1623
} catch (e) {
1724
console.log("❌ FAIL: Error loading ES module:", e.message);
1825
failed++;

test-app/runtime/src/main/java/com/tns/Runtime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public Runtime(StaticConfiguration config, DynamicConfiguration dynamicConfigura
223223

224224
gcListener = GcListener.getInstance(config.appConfig.getGcThrottleTime(), config.appConfig.getMemoryCheckInterval(), config.appConfig.getFreeMemoryRatio());
225225
// capture static configuration to allow native lookups when currentRuntime is unavailable
226-
Runtime.staticConfiguration = config;
226+
staticConfiguration = config;
227227
} finally {
228228
frame.close();
229229
}

test-app/tools/check_console_test_results.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function checkTestResults() {
2020

2121
// Track different types of test results
2222
const testResults = {
23-
esModules: { passed: false, failed: false },
23+
esModules: { passed: false, failed: false, total: 0, passedCount: 0, failedCount: 0 },
2424
jasmine: { specs: 0, failures: 0 },
2525
manual: { tests: [], failures: [] },
2626
general: { passes: 0, failures: 0 }
@@ -29,6 +29,13 @@ function checkTestResults() {
2929
// Look for ES Module test results
3030
testResults.esModules.passed = logcatOutput.includes('ALL ES MODULE TESTS PASSED!');
3131
testResults.esModules.failed = logcatOutput.includes('SOME ES MODULE TESTS FAILED!');
32+
// Parse ES Module counts if present
33+
const esmPassedMatch = logcatOutput.match(/Tests passed:\s*(\d+)/);
34+
const esmFailedMatch = logcatOutput.match(/Tests failed:\s*(\d+)/);
35+
const esmTotalMatch = logcatOutput.match(/Total tests:\s*(\d+)/);
36+
if (esmPassedMatch) testResults.esModules.passedCount = parseInt(esmPassedMatch[1], 10);
37+
if (esmFailedMatch) testResults.esModules.failedCount = parseInt(esmFailedMatch[1], 10);
38+
if (esmTotalMatch) testResults.esModules.total = parseInt(esmTotalMatch[1], 10);
3239

3340
// Look for Jasmine test results
3441
const jasmineSuccessMatch = logcatOutput.match(/SUCCESS:\s*(\d+)\s+specs?,\s*(\d+)\s+failures?/);
@@ -83,10 +90,15 @@ function checkTestResults() {
8390
console.log('='.repeat(50));
8491

8592
// ES Module tests
86-
if (testResults.esModules.passed) {
87-
console.log('✅ ES Module Tests: PASSED');
88-
} else if (testResults.esModules.failed) {
89-
console.log('❌ ES Module Tests: FAILED');
93+
if (testResults.esModules.passed || testResults.esModules.failed) {
94+
const esmCounts = testResults.esModules.total
95+
? ` (${testResults.esModules.passedCount}/${testResults.esModules.total} passed, ${testResults.esModules.failedCount} failed)`
96+
: '';
97+
if (testResults.esModules.passed) {
98+
console.log(`✅ ES Module Tests: PASSED${esmCounts}`);
99+
} else if (testResults.esModules.failed) {
100+
console.log(`❌ ES Module Tests: FAILED${esmCounts}`);
101+
}
90102
} else {
91103
console.log('ES Module Tests: No clear results found');
92104
}
@@ -115,6 +127,14 @@ function checkTestResults() {
115127
console.log(`📈 General Results: ${testResults.general.passes} passes, ${testResults.general.failures} failures`);
116128
}
117129

130+
// Totals across detected test suites
131+
const totalDetectedTests = (testResults.jasmine.specs || 0) + (testResults.esModules.total || 0);
132+
if (totalDetectedTests > 0) {
133+
const totalFailures = (testResults.jasmine.failures || 0) + (testResults.esModules.failedCount || 0);
134+
console.log(`—`);
135+
console.log(`🧮 Total Detected Tests: ${totalDetectedTests} (Jasmine: ${testResults.jasmine.specs || 0}, ES Modules: ${testResults.esModules.total || 0})`);
136+
console.log(` Total Failures: ${totalFailures}`);
137+
}
118138
console.log('='.repeat(50));
119139

120140
// Show recent test output for debugging
@@ -141,6 +161,9 @@ function checkTestResults() {
141161
logContent.includes('SUCCESS:') ||
142162
logContent.includes('FAILURE:') ||
143163
logContent.includes('ES MODULE') ||
164+
logContent.includes('Total tests:') ||
165+
logContent.includes('Tests passed:') ||
166+
logContent.includes('Tests failed:') ||
144167
logContent.includes('FAILED TEST:') ||
145168
logContent.includes('Suite:') ||
146169
logContent.includes('File:') ||

0 commit comments

Comments
 (0)