deflake 1.2.3 â 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +59 -0
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -62,6 +62,11 @@ const parser = yargs(hideBin(process.argv))
|
|
|
62
62
|
description: 'Diagnose your DeFlake installation',
|
|
63
63
|
default: false
|
|
64
64
|
})
|
|
65
|
+
.option('report', {
|
|
66
|
+
type: 'boolean',
|
|
67
|
+
description: 'Automatically open the HTML report after fixing',
|
|
68
|
+
default: true
|
|
69
|
+
})
|
|
65
70
|
.command('doctor', 'Diagnose your DeFlake installation', {}, (argv) => {
|
|
66
71
|
runDoctor(argv).then(() => process.exit(0));
|
|
67
72
|
})
|
|
@@ -749,6 +754,55 @@ async function applySelfHealing(result) {
|
|
|
749
754
|
}
|
|
750
755
|
}
|
|
751
756
|
|
|
757
|
+
/**
|
|
758
|
+
* Automagically opens the framework's native HTML report.
|
|
759
|
+
*/
|
|
760
|
+
function showFrameworkReport() {
|
|
761
|
+
const framework = DeFlakeClient.detectFramework();
|
|
762
|
+
console.log(`\n${C.CYAN}đ Opening HTML Report for ${framework.toUpperCase()}...${C.RESET}`);
|
|
763
|
+
|
|
764
|
+
let command = '';
|
|
765
|
+
const opener = process.platform === 'win32' ? 'start' : 'open';
|
|
766
|
+
|
|
767
|
+
if (framework === 'playwright') {
|
|
768
|
+
command = 'npx playwright show-report';
|
|
769
|
+
} else if (framework === 'cypress') {
|
|
770
|
+
// Broad search for common Cypress HTML reports
|
|
771
|
+
const candidates = [
|
|
772
|
+
'cypress/reports/html/index.html',
|
|
773
|
+
'cypress/reports/index.html',
|
|
774
|
+
'mochawesome-report/mochawesome.html',
|
|
775
|
+
'reports/index.html'
|
|
776
|
+
];
|
|
777
|
+
|
|
778
|
+
const found = candidates.find(p => fs.existsSync(p));
|
|
779
|
+
if (found) {
|
|
780
|
+
command = `${opener} ${found}`;
|
|
781
|
+
} else {
|
|
782
|
+
console.log(`${C.GRAY}âšī¸ Cypress HTML report not found. Verify your reporter configuration (e.g. mochawesome).${C.RESET}`);
|
|
783
|
+
console.log(` ${C.GRAY}Looked in: ${candidates.join(', ')}${C.RESET}`);
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
} else if (framework === 'webdriverio') {
|
|
787
|
+
// WDIO usually uses Allure or spec-reporter
|
|
788
|
+
if (fs.existsSync('allure-results')) {
|
|
789
|
+
console.log(` ${C.GRAY}Allure results detected. Attempting to serve...${C.RESET}`);
|
|
790
|
+
command = 'npx allure serve allure-results';
|
|
791
|
+
} else if (fs.existsSync('reports/html/index.html')) {
|
|
792
|
+
command = `${opener} reports/html/index.html`;
|
|
793
|
+
} else {
|
|
794
|
+
console.log(`${C.GRAY}âšī¸ WebdriverIO HTML report not found. If you use Allure, ensure allure-results folder exists.${C.RESET}`);
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
if (command) {
|
|
800
|
+
// Use inherit if it's a server (like allure serve) or a long-running process
|
|
801
|
+
const isServer = command.includes('serve') || command.includes('show-report');
|
|
802
|
+
spawn(command, { shell: true, stdio: isServer ? 'inherit' : 'ignore' });
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
|
|
752
806
|
async function analyzeFailures(artifacts, fullLog, client) {
|
|
753
807
|
if (artifacts.length === 0) {
|
|
754
808
|
console.log("â ī¸ No error artifacts found.");
|
|
@@ -892,6 +946,11 @@ async function analyzeFailures(artifacts, fullLog, client) {
|
|
|
892
946
|
} else if (!argv.fix) {
|
|
893
947
|
console.log(`\n${C.BRIGHT}đĄ Tip: Use ${C.CYAN}--fix${C.RESET}${C.BRIGHT} to automatically apply these suggested fixes next time.${C.RESET}`);
|
|
894
948
|
}
|
|
949
|
+
|
|
950
|
+
// TRIGGER REPORT
|
|
951
|
+
if (results.length > 0 && argv.fix && argv.report) {
|
|
952
|
+
showFrameworkReport();
|
|
953
|
+
}
|
|
895
954
|
}
|
|
896
955
|
|
|
897
956
|
async function main() {
|