-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopen-report.ts
More file actions
34 lines (26 loc) · 918 Bytes
/
open-report.ts
File metadata and controls
34 lines (26 loc) · 918 Bytes
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
import { exec } from 'child_process';
import * as path from 'path';
import { promisify } from 'util';
const execAsync = promisify(exec);
interface PlatformCommands {
[key: string]: string;
}
async function openCucumberReport(): Promise<void> {
const reportPath: string = path.join(process.cwd(), 'test-results', 'cucumber-report.html');
const platformCommands: PlatformCommands = {
'win32': `start "" "${reportPath}"`,
'darwin': `open "${reportPath}"`,
'linux': `xdg-open "${reportPath}"`
};
const command: string = platformCommands[process.platform] || `xdg-open "${reportPath}"`;
try {
await execAsync(command);
console.log('✅ Cucumber report opened in browser');
} catch (error) {
console.error('❌ Error opening report:', error);
}
}
if (require.main === module) {
openCucumberReport();
}
export { openCucumberReport };