Repository navigation
Expand file tree
/
Copy pathtest-m6-comprehensive.js
More file actions
executable file
Β·224 lines (182 loc) Β· 6 KB
/
Copy pathtest-m6-comprehensive.js
File metadata and controls
executable file
Β·224 lines (182 loc) Β· 6 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/usr/bin/env node
/**
* M6 Comprehensive Test Runner
* Runs all test suites and generates comprehensive reports
*/
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
function runTestSuite(testName, command, description) {
console.log(`\nπ§ͺ Running ${testName}...`);
console.log(`π ${description}`);
try {
const startTime = Date.now();
execSync(command, { stdio: 'inherit' });
const endTime = Date.now();
const duration = endTime - startTime;
console.log(`β
${testName} completed in ${duration}ms`);
return { status: 'success', duration };
} catch (error) {
console.log(`β ${testName} failed: ${error.message}`);
return { status: 'failed', error: error.message };
}
}
function generateTestReport(results) {
const report = {
timestamp: new Date().toISOString(),
summary: {
total: results.length,
success: results.filter(r => r.status === 'success').length,
failed: results.filter(r => r.status === 'failed').length
},
results
};
// Save JSON report
const reportPath = path.join(__dirname, 'test-results.json');
fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));
// Generate markdown report
const markdownReport = `# M6 Comprehensive Test Report
**Generated:** ${report.timestamp}
## Summary
| Status | Count |
|--------|-------|
| β
Success | ${report.summary.success} |
| β Failed | ${report.summary.failed} |
| **Total** | **${report.summary.total}** |
## Detailed Results
${results.map(result => `
### ${result.name}
**Status:** ${result.status === 'success' ? 'β
' : 'β'} ${result.status.toUpperCase()}
**Duration:** ${result.duration ? `${result.duration}ms` : 'N/A'}
**Description:** ${result.description}
${result.error ? `**Error:** \`${result.error}\`` : ''}
`).join('')}
## Recommendations
${report.summary.failed > 0 ?
'β Some tests failed. Please review the errors above and fix them before proceeding.' :
'β
All tests passed! The system is ready for deployment.'}
`;
const markdownPath = path.join(__dirname, 'test-results.md');
fs.writeFileSync(markdownPath, markdownReport);
console.log(`\nπ Test report saved to: ${reportPath}`);
console.log(`π Markdown report saved to: ${markdownPath}`);
return report;
}
function main() {
console.log('π M6 Comprehensive Test Runner');
console.log('================================\n');
const results = [];
// Test 1: Unit Tests
results.push(runTestSuite(
'Unit Tests',
'npm run test:unit',
'Testing individual components and functions'
));
// Test 2: Integration Tests
results.push(runTestSuite(
'Integration Tests',
'npm run test:integration',
'Testing API endpoints and service interactions'
));
// Test 3: Performance Tests
results.push(runTestSuite(
'Performance Tests',
'npm run test:performance',
'Testing system performance and load handling'
));
// Test 4: Security Tests
results.push(runTestSuite(
'Security Tests',
'npm run test:security',
'Testing security vulnerabilities and access controls'
));
// Test 5: E2E Tests
results.push(runTestSuite(
'End-to-End Tests',
'npm run test:e2e',
'Testing complete user journeys and workflows'
));
// Test 6: Accessibility Tests
results.push(runTestSuite(
'Accessibility Tests',
'npm run test:accessibility',
'Testing website accessibility compliance'
));
// Test 7: API Contract Tests
results.push(runTestSuite(
'API Contract Tests',
'npm run test:api-contract',
'Testing API contract compliance and OpenAPI validation'
));
// Test 8: Load Tests
results.push(runTestSuite(
'Load Tests',
'npm run test:load',
'Testing system performance under load'
));
// Test 9: Stress Tests
results.push(runTestSuite(
'Stress Tests',
'npm run test:stress',
'Testing system behavior under extreme conditions'
));
// Test 10: Code Quality
results.push(runTestSuite(
'Code Quality',
'npm run lint:check && npm run format:check',
'Testing code quality and formatting standards'
));
// Test 11: Type Safety
results.push(runTestSuite(
'Type Safety',
'npm run type-check',
'Testing TypeScript compilation and type safety'
));
// Test 12: Security Audit
results.push(runTestSuite(
'Security Audit',
'npm audit --audit-level=moderate',
'Testing for security vulnerabilities in dependencies'
));
// Test 13: Environment Validation
results.push(runTestSuite(
'Environment Validation',
'node scripts/validate-env.js',
'Validating environment configuration and required variables'
));
// Test 14: Database Migration Check
results.push(runTestSuite(
'Database Migration Check',
'npm run db:migrate:check',
'Checking database migration status'
));
// Test 15: OpenAPI Validation
results.push(runTestSuite(
'OpenAPI Validation',
'npm run openapi:validate',
'Validating API documentation and OpenAPI specification'
));
// Generate comprehensive report
const report = generateTestReport(results);
// Print final summary
console.log('\nπ― M6 Test Summary');
console.log('==================');
console.log(`β
Successful: ${report.summary.success}`);
console.log(`β Failed: ${report.summary.failed}`);
console.log(`π Total: ${report.summary.total}`);
console.log(`π― Success Rate: ${((report.summary.success / report.summary.total) * 100).toFixed(1)}%`);
if (report.summary.failed > 0) {
console.log('\nβ Some tests failed. Please review the errors above.');
console.log('π‘ Check the test-results.md file for detailed information.');
process.exit(1);
} else {
console.log('\nπ All tests passed! The system is ready for deployment.');
console.log('β
M6 Testing & Quality milestone completed successfully!');
process.exit(0);
}
}
// Run the comprehensive test suite
if (require.main === module) {
main();
}
module.exports = { main };