@flash-ai-team/flash-test-framework 0.0.9 → 0.0.10

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
@@ -2,22 +2,53 @@
2
2
 
3
3
  A powerful, keyword-driven automation framework built on top of Playwright and TypeScript, featuring AI-powered capabilities.
4
4
 
5
- ## Installation
5
+ ## Quick Start
6
+
7
+ The easiest way to start a new project is using our CLI.
8
+
9
+ ### Global Installation
10
+
11
+ Alternatively, you can install the CLI globally to run `flash-test` commands directly.
6
12
 
7
13
  ```bash
8
- npm install @flash-ai-team/flash-test-framework
14
+ npm install -g @flash-ai-team/flash-test-framework
9
15
  ```
10
16
 
11
- ## Setup
17
+ Then you can use:
12
18
 
13
- 1. **Initialize Playwright** (if not already done):
19
+ ```bash
20
+ flash-test init <project-name>
21
+ flash-test --version
22
+ ```
23
+
24
+ 1. **Initialize a new project**:
25
+ Make a new folder and run:
14
26
  ```bash
15
- npx playwright install
27
+ flash-test init <project-name>
16
28
  ```
29
+ This will create:
30
+ * `package.json` with dependencies.
31
+ * `playwright.config.ts` configured for the framework.
32
+ * `tsconfig.json`.
33
+ * `tests/cases/ExampleTests.ts` and `tests/suites/Example.spec.ts`.
34
+
35
+ 2. **Install dependencies**:
36
+ ```bash
37
+ npm install
38
+ ```
39
+
40
+ 4. **Run the test**:
41
+ ```bash
42
+ npx playwright test
43
+ ```
44
+
45
+ ## Manual Setup (Optional)
17
46
 
18
- 2. **Configuration**:
19
- * **Email Reporting**: Create `email.config.json` in your project root if you want email reports.
20
- * **AI Features**: Create `ai.config.json` with your OpenAI API key to use `AIWeb`.
47
+ If you prefer to set up manually:
48
+ 1. `npm install @flash-ai-team/flash-test-framework`
49
+ 2. Create `playwright.config.ts` and `tsconfig.json`.
50
+ 3. **Email Reporting**: Create `email.config.json`.
51
+ 4. **AI Features**: Create `ai.config.json`:
21
52
  ```json
22
53
  {
23
54
  "enabled": true,
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const args = process.argv.slice(2);
10
+ const command = args[0];
11
+ if (command === 'init') {
12
+ const projectName = args[1];
13
+ initProject(projectName);
14
+ }
15
+ else if (command === '--version' || command === '-v') {
16
+ printVersion();
17
+ }
18
+ else {
19
+ console.log('Usage: flash-test init [project-name]');
20
+ console.log(' flash-test -v / --version');
21
+ process.exit(1);
22
+ }
23
+ function printVersion() {
24
+ try {
25
+ const packageJsonPath = path_1.default.join(__dirname, '..', '..', 'package.json');
26
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf-8'));
27
+ console.log(`v${packageJson.version}`);
28
+ }
29
+ catch (error) {
30
+ console.error('Error reading version:', error);
31
+ process.exit(1);
32
+ }
33
+ }
34
+ function initProject(projectName) {
35
+ console.log('Initializing Flash Test Project...');
36
+ let projectDir = process.cwd();
37
+ let name = "my-flash-test-project";
38
+ if (projectName) {
39
+ projectDir = path_1.default.join(process.cwd(), projectName);
40
+ name = projectName;
41
+ if (!fs_1.default.existsSync(projectDir)) {
42
+ fs_1.default.mkdirSync(projectDir);
43
+ console.log(`Created directory: ${projectName}`);
44
+ }
45
+ }
46
+ // 1. Create Files
47
+ createFile(path_1.default.join(projectDir, 'package.json'), JSON.stringify({
48
+ "name": name,
49
+ "version": "1.0.0",
50
+ "scripts": {
51
+ "test": "playwright test"
52
+ },
53
+ "devDependencies": {
54
+ "@flash-ai-team/flash-test-framework": "latest",
55
+ "@playwright/test": "^1.57.0",
56
+ "typescript": "^5.9.3"
57
+ }
58
+ }, null, 2));
59
+ createFile(path_1.default.join(projectDir, 'playwright.config.ts'), `
60
+ import { defineConfig, devices } from '@playwright/test';
61
+
62
+ export default defineConfig({
63
+ testDir: './tests',
64
+ fullyParallel: true,
65
+ forbidOnly: !!process.env.CI,
66
+ retries: process.env.CI ? 2 : 0,
67
+ workers: process.env.CI ? 1 : undefined,
68
+ reporter: [
69
+ ['html', { open: 'never' }],
70
+ ['list'], // Keep 'list' for console output
71
+ [require.resolve('@flash-ai-team/flash-test-framework/dist/reporting/CustomReporter.js')],
72
+ [require.resolve('@flash-ai-team/flash-test-framework/dist/reporting/HtmlReporter.js')]
73
+ ],
74
+ use: {
75
+ trace: 'on-first-retry',
76
+ },
77
+ projects: [
78
+ {
79
+ name: 'chrome',
80
+ use: { ...devices['Desktop Chrome'] },
81
+ },
82
+ ],
83
+ });
84
+ `);
85
+ createFile(path_1.default.join(projectDir, 'tsconfig.json'), JSON.stringify({
86
+ "compilerOptions": {
87
+ "target": "es2016",
88
+ "module": "commonjs",
89
+ "esModuleInterop": true,
90
+ "forceConsistentCasingInFileNames": true,
91
+ "strict": true,
92
+ "skipLibCheck": true
93
+ }
94
+ }, null, 2));
95
+ createFile(path_1.default.join(projectDir, '.gitignore'), `
96
+ node_modules/
97
+ test-results/
98
+ playwright-report/
99
+ dist/
100
+ `);
101
+ const testsDir = path_1.default.join(projectDir, 'tests');
102
+ const casesDir = path_1.default.join(testsDir, 'cases');
103
+ const suitesDir = path_1.default.join(testsDir, 'suites');
104
+ if (!fs_1.default.existsSync(testsDir))
105
+ fs_1.default.mkdirSync(testsDir);
106
+ if (!fs_1.default.existsSync(casesDir))
107
+ fs_1.default.mkdirSync(casesDir);
108
+ if (!fs_1.default.existsSync(suitesDir))
109
+ fs_1.default.mkdirSync(suitesDir);
110
+ createFile(path_1.default.join(casesDir, 'ExampleTests.ts'), `
111
+ import { Web, el, TestCase } from '@flash-ai-team/flash-test-framework';
112
+
113
+ export class ExampleTests {
114
+
115
+ @TestCase
116
+ static async BasicVerify() {
117
+ await Web.navigateToUrl('https://example.com');
118
+ await Web.verifyTextPresent('Example Domain');
119
+
120
+ const header = el('h1', 'Header');
121
+ await Web.verifyElementPresent(header);
122
+ }
123
+ }
124
+ `);
125
+ createFile(path_1.default.join(suitesDir, 'Example.spec.ts'), `
126
+ import { test } from '@flash-ai-team/flash-test-framework';
127
+ import { ExampleTests } from '../cases/ExampleTests';
128
+
129
+ test.describe('Example Suite', () => {
130
+ test('Basic Verification', async () => {
131
+ await ExampleTests.BasicVerify();
132
+ });
133
+ });
134
+ `);
135
+ console.log('Project initialized successfully!');
136
+ if (projectName) {
137
+ console.log(`\nNext steps:\n cd ${projectName}\n npm install`);
138
+ }
139
+ else {
140
+ console.log('Run "npm install" to install dependencies.');
141
+ }
142
+ }
143
+ function createFile(filePath, content) {
144
+ if (fs_1.default.existsSync(filePath)) {
145
+ console.log(`Skipping existing file: ${path_1.default.basename(filePath)}`);
146
+ }
147
+ else {
148
+ fs_1.default.writeFileSync(filePath, content.trim());
149
+ console.log(`Created: ${path_1.default.basename(filePath)}`);
150
+ }
151
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flash-ai-team/flash-test-framework",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "A powerful keyword-driven automation framework built on top of Playwright and TypeScript.",
5
5
  "keywords": [
6
6
  "playwright",
@@ -24,6 +24,9 @@
24
24
  "type": "commonjs",
25
25
  "main": "dist/index.js",
26
26
  "types": "dist/index.d.ts",
27
+ "bin": {
28
+ "flash-test": "./dist/cli/index.js"
29
+ },
27
30
  "directories": {
28
31
  "test": "tests"
29
32
  },