forked from DexterLabZ/syrius-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-runner.js
More file actions
executable file
·123 lines (101 loc) · 2.7 KB
/
Copy pathtest-runner.js
File metadata and controls
executable file
·123 lines (101 loc) · 2.7 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
#!/usr/bin/env node
// Test runner script to handle test execution with proper configuration
const { spawn } = require('child_process');
const path = require('path');
// Get command line arguments
const args = process.argv.slice(2);
const testType = args[0] || 'all';
// Define test configurations
const testConfigs = {
// Run only new comprehensive tests (Phase 2-4)
comprehensive: {
testPathPattern: '__tests__/(components|integration|edge-cases|security|performance)',
testTimeout: 30000,
verbose: true
},
// Run only security tests
security: {
testPathPattern: '__tests__/security',
testTimeout: 15000,
verbose: true
},
// Run only performance tests
performance: {
testPathPattern: '__tests__/performance',
testTimeout: 20000,
verbose: true
},
// Run edge cases tests
edge: {
testPathPattern: '__tests__/edge-cases',
testTimeout: 15000,
verbose: true
},
// Run integration tests
integration: {
testPathPattern: '__tests__/integration',
testTimeout: 20000,
verbose: true
},
// Run component tests
components: {
testPathPattern: '__tests__/components',
testTimeout: 10000,
verbose: true
},
// Quick test - just run a few key tests
quick: {
testPathPattern: '__tests__/(security|performance)/.*\\.test\\.js$',
testTimeout: 10000,
maxWorkers: 1
},
// Run all tests (default)
all: {
testTimeout: 30000,
verbose: false,
maxWorkers: 1
}
};
// Get configuration
const config = testConfigs[testType] || testConfigs.all;
// Build Jest command
const jestArgs = [
'--colors',
'--detectOpenHandles',
'--forceExit'
];
// Add configuration options
if (config.testPathPattern) {
jestArgs.push('--testPathPattern', config.testPathPattern);
}
if (config.testTimeout) {
jestArgs.push('--testTimeout', config.testTimeout.toString());
}
if (config.verbose) {
jestArgs.push('--verbose');
}
if (config.maxWorkers) {
jestArgs.push('--maxWorkers', config.maxWorkers.toString());
}
// Add coverage if requested
if (args.includes('--coverage')) {
jestArgs.push('--coverage');
}
// Add watch mode if requested
if (args.includes('--watch')) {
jestArgs.push('--watch');
}
console.log(`Running ${testType} tests...`);
console.log('Jest command:', 'npx jest', jestArgs.join(' '));
// Execute Jest
const jestProcess = spawn('npx', ['jest', ...jestArgs], {
stdio: 'inherit',
cwd: process.cwd()
});
jestProcess.on('close', (code) => {
process.exit(code);
});
jestProcess.on('error', (error) => {
console.error('Failed to start Jest:', error);
process.exit(1);
});