@flash-ai-team/flash-test-framework 0.0.13 → 0.0.15

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/README.md CHANGED
@@ -18,9 +18,25 @@ Then you can use:
18
18
 
19
19
  ```bash
20
20
  flash-test init <project-name>
21
+ flash-test run <suite-name> [-browser <browser>]
22
+ flash-test latest-run <suite-name>
23
+ flash-test history [suite-name]
21
24
  flash-test --version
22
25
  ```
23
26
 
27
+ ### Commands
28
+
29
+ * `init <project-name>`: Initialize a new project structure.
30
+ * `run <suite-name>`: Run a specific test suite.
31
+ * Example: `flash-test run parallel_suite`
32
+ * Example: `flash-test run parallel_suite -browser firefox`
33
+ * `latest-run <suite-name>`: View the status of the most recent run for a suite.
34
+ * Example: `flash-test latest-run parallel_suite`
35
+ * `history [suite-name]`: View historical test runs and open the HTML dashboard.
36
+ * Example: `flash-test history` (All suites)
37
+ * Example: `flash-test history parallel_suite` (Specific suite)
38
+ * `--version`: Show CLI version.
39
+
24
40
  1. **Initialize a new project**:
25
41
  Make a new folder and run:
26
42
  ```bash
package/dist/cli/index.js CHANGED
@@ -20,8 +20,17 @@ else if (command === 'history') {
20
20
  const suiteName = args[1];
21
21
  showHistory(suiteName);
22
22
  }
23
+ else if (command === 'run') {
24
+ runSuite(args.slice(1));
25
+ }
26
+ else if (command === 'latest-run') {
27
+ const suiteName = args[1];
28
+ showLatestRun(suiteName);
29
+ }
23
30
  else {
24
31
  console.log('Usage: flash-test init [project-name]');
32
+ console.log(' flash-test run <suite-name> [-browser <browser-name>]');
33
+ console.log(' flash-test latest-run <suite-name>');
25
34
  console.log(' flash-test history [suite-name]');
26
35
  console.log(' flash-test -v / --version');
27
36
  process.exit(1);
@@ -336,3 +345,93 @@ function generateHistoryHtml(runs, reportsDir) {
336
345
  console.log('Could not auto-open browser. Please open the file manually.');
337
346
  }
338
347
  }
348
+ function runSuite(args) {
349
+ const suiteName = args[0];
350
+ if (!suiteName) {
351
+ console.error('Error: Suite name is required.');
352
+ console.log('Usage: flash-test run <suite-name> [-browser <browser-name>]');
353
+ process.exit(1);
354
+ }
355
+ const suitePath = `tests/suites/${suiteName}.spec.ts`;
356
+ if (!fs_1.default.existsSync(path_1.default.join(process.cwd(), suitePath))) {
357
+ console.error(`Error: Suite file not found at ${suitePath}`);
358
+ process.exit(1);
359
+ }
360
+ let cmd = `npx playwright test ${suitePath}`;
361
+ // Check for -browser flag
362
+ const browserIndex = args.indexOf('-browser');
363
+ if (browserIndex !== -1 && args[browserIndex + 1]) {
364
+ const browser = args[browserIndex + 1];
365
+ cmd += ` --project=${browser}`;
366
+ }
367
+ console.log(`Executing: ${cmd}`);
368
+ try {
369
+ (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
370
+ }
371
+ catch (e) {
372
+ process.exit(1);
373
+ }
374
+ }
375
+ function showLatestRun(suiteName) {
376
+ if (!suiteName) {
377
+ console.error('Error: Suite name is required for latest-run.');
378
+ process.exit(1);
379
+ }
380
+ const reportsDir = path_1.default.join(process.cwd(), 'reports', suiteName);
381
+ if (!fs_1.default.existsSync(reportsDir)) {
382
+ console.log(`No reports found for suite: ${suiteName}`);
383
+ return;
384
+ }
385
+ // Find latest timestamp folder
386
+ const runs = fs_1.default.readdirSync(reportsDir)
387
+ .filter(f => f.startsWith('test_') && fs_1.default.statSync(path_1.default.join(reportsDir, f)).isDirectory())
388
+ .sort((a, b) => b.localeCompare(a)); // Reverse sort to get newest first
389
+ if (runs.length === 0) {
390
+ console.log(`No runs found for suite: ${suiteName}`);
391
+ return;
392
+ }
393
+ const latestRun = runs[0];
394
+ const runPath = path_1.default.join(reportsDir, latestRun);
395
+ const jsonPath = path_1.default.join(runPath, 'custom-report.json');
396
+ console.log(`\nLatest Run: ${suiteName}`);
397
+ console.log(`Timestamp: ${latestRun.replace('test_', '')}`);
398
+ console.log(`Report Path: ${runPath}`);
399
+ console.log('----------------------------------------');
400
+ if (fs_1.default.existsSync(jsonPath)) {
401
+ try {
402
+ const data = JSON.parse(fs_1.default.readFileSync(jsonPath, 'utf-8'));
403
+ let status = 'Unknown';
404
+ let passed = 0;
405
+ let failed = 0;
406
+ let duration = 0;
407
+ if (Array.isArray(data)) {
408
+ passed = data.filter((t) => t.status === 'passed').length;
409
+ failed = data.filter((t) => t.status === 'failed' || t.status === 'timedOut').length;
410
+ duration = data.reduce((acc, curr) => acc + (curr.duration || 0), 0);
411
+ status = failed > 0 ? 'Failed' : (passed > 0 ? 'Passed' : 'No Tests');
412
+ }
413
+ else if (data.stats) {
414
+ passed = data.stats.passed;
415
+ failed = data.stats.failed;
416
+ duration = data.stats.duration;
417
+ status = failed > 0 ? 'Failed' : 'Passed';
418
+ }
419
+ const colorFn = status === 'Failed' ? '\x1b[31m' : '\x1b[32m'; // Red or Green
420
+ const reset = '\x1b[0m';
421
+ console.log(`Status: ${colorFn}${status}${reset}`);
422
+ console.log(`Passed: ${passed}`);
423
+ console.log(`Failed: ${failed}`);
424
+ console.log(`Duration: ${(duration / 1000).toFixed(2)}s`);
425
+ if (failed > 0) {
426
+ console.log(`\n${colorFn}Errors detected! Check report for details.${reset}`);
427
+ }
428
+ }
429
+ catch (e) {
430
+ console.error('Error parsing report data.');
431
+ }
432
+ }
433
+ else {
434
+ console.log('Report data not found.');
435
+ }
436
+ console.log('');
437
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flash-ai-team/flash-test-framework",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "A powerful keyword-driven automation framework built on top of Playwright and TypeScript.",
5
5
  "keywords": [
6
6
  "playwright",