deflake 1.2.3 â 1.2.5
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 +68 -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,64 @@ 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
|
+
// Playwright default report port is 9323. Try to close previous instance if on Mac/Linux
|
|
769
|
+
try {
|
|
770
|
+
if (process.platform !== 'win32') {
|
|
771
|
+
const pid = require('child_process').execSync('lsof -t -i:9323').toString().trim();
|
|
772
|
+
if (pid) {
|
|
773
|
+
require('child_process').execSync(`kill ${pid}`);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
} catch (e) {}
|
|
777
|
+
command = 'npx playwright show-report';
|
|
778
|
+
} else if (framework === 'cypress') {
|
|
779
|
+
// Broad search for common Cypress HTML reports
|
|
780
|
+
const candidates = [
|
|
781
|
+
'cypress/reports/html/index.html',
|
|
782
|
+
'cypress/reports/index.html',
|
|
783
|
+
'mochawesome-report/mochawesome.html',
|
|
784
|
+
'reports/index.html'
|
|
785
|
+
];
|
|
786
|
+
|
|
787
|
+
const found = candidates.find(p => fs.existsSync(p));
|
|
788
|
+
if (found) {
|
|
789
|
+
command = `${opener} ${found}`;
|
|
790
|
+
} else {
|
|
791
|
+
console.log(`${C.GRAY}âšī¸ Cypress HTML report not found. Verify your reporter configuration (e.g. mochawesome).${C.RESET}`);
|
|
792
|
+
console.log(` ${C.GRAY}Looked in: ${candidates.join(', ')}${C.RESET}`);
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
} else if (framework === 'webdriverio') {
|
|
796
|
+
// WDIO usually uses Allure or spec-reporter
|
|
797
|
+
if (fs.existsSync('allure-results')) {
|
|
798
|
+
console.log(` ${C.GRAY}Allure results detected. Attempting to serve...${C.RESET}`);
|
|
799
|
+
command = 'npx allure serve allure-results';
|
|
800
|
+
} else if (fs.existsSync('reports/html/index.html')) {
|
|
801
|
+
command = `${opener} reports/html/index.html`;
|
|
802
|
+
} else {
|
|
803
|
+
console.log(`${C.GRAY}âšī¸ WebdriverIO HTML report not found. If you use Allure, ensure allure-results folder exists.${C.RESET}`);
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
if (command) {
|
|
809
|
+
// Use inherit if it's a server (like allure serve) or a long-running process
|
|
810
|
+
const isServer = command.includes('serve') || command.includes('show-report');
|
|
811
|
+
spawn(command, { shell: true, stdio: isServer ? 'inherit' : 'ignore' });
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
752
815
|
async function analyzeFailures(artifacts, fullLog, client) {
|
|
753
816
|
if (artifacts.length === 0) {
|
|
754
817
|
console.log("â ī¸ No error artifacts found.");
|
|
@@ -892,6 +955,11 @@ async function analyzeFailures(artifacts, fullLog, client) {
|
|
|
892
955
|
} else if (!argv.fix) {
|
|
893
956
|
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
957
|
}
|
|
958
|
+
|
|
959
|
+
// TRIGGER REPORT
|
|
960
|
+
if (results.length > 0 && argv.fix && argv.report) {
|
|
961
|
+
showFrameworkReport();
|
|
962
|
+
}
|
|
895
963
|
}
|
|
896
964
|
|
|
897
965
|
async function main() {
|