-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple-test.js
More file actions
76 lines (64 loc) · 2.13 KB
/
simple-test.js
File metadata and controls
76 lines (64 loc) · 2.13 KB
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
#!/usr/bin/env node
/**
* Simple standalone test runner for CodeSense
* Run with: node simple-test.js
*/
import { baselineCheck } from './out/baseline.js';
import { CompatibilityScanner } from './out/scanner.js';
import { ReportGenerator } from './out/report.js';
console.log('🧪 Starting simple CodeSense tests...\n');
let passCount = 0;
let failCount = 0;
async function test(name, fn) {
try {
await fn();
console.log(`✅ ${name}`);
passCount++;
} catch (error) {
console.log(`❌ ${name}`);
console.log(` Error: ${error.message}`);
failCount++;
}
}
async function runTests() {
// Test 1: Baseline check for fetch API
await test('Baseline check returns status for fetch', async () => {
const status = await baselineCheck('fetch');
if (!status || status === '❓ Unknown') {
throw new Error(`Expected known status, got: ${status}`);
}
});
// Test 2: Scanner initialization
await test('Scanner can be initialized', () => {
const scanner = new CompatibilityScanner();
if (!scanner) {
throw new Error('Scanner failed to initialize');
}
});
// Test 3: Report generator initialization
await test('ReportGenerator can be initialized', () => {
const reportGen = new ReportGenerator();
if (!reportGen) {
throw new Error('ReportGenerator failed to initialize');
}
});
// Test 4: Baseline check for unknown feature
await test('Baseline check returns Unknown for non-existent feature', async () => {
const status = await baselineCheck('totally-fake-api-that-does-not-exist');
if (status !== '❓ Unknown') {
throw new Error(`Expected Unknown status, got: ${status}`);
}
});
// Summary
console.log('\n' + '='.repeat(50));
console.log(`✅ Passed: ${passCount}`);
console.log(`❌ Failed: ${failCount}`);
console.log('='.repeat(50));
if (failCount > 0) {
process.exit(1);
}
}
runTests().catch(error => {
console.error('💥 Test runner crashed:', error);
process.exit(1);
});