@playwright-test-runner/core 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,321 @@
1
+ # Playwright Test Runner Library
2
+
3
+ Libreria agnostica per eseguire test Playwright con server Express e UI report. Può essere installata in qualsiasi progetto TypeScript/JavaScript per eseguire test E2E.
4
+
5
+ ## Caratteristiche
6
+
7
+ - Server Express con API REST per eseguire test Playwright
8
+ - Lettura automatica dei file `.spec.ts` dalla cartella `tests`
9
+ - Report UI integrato di Playwright
10
+ - Completamente agnostico dal contesto del progetto
11
+ - Facile integrazione in progetti esistenti
12
+
13
+ ## Installazione
14
+
15
+ ```bash
16
+ npm install @playwright-test-runner/core
17
+ ```
18
+
19
+ **IMPORTANTE:** La libreria include già Playwright e tutti i browser necessari. **NON serve installare** `@playwright/test` o eseguire `npx playwright install` nel tuo progetto!
20
+
21
+ ## Utilizzo
22
+
23
+ ### 1. Setup (Solo 2 Passi!)
24
+
25
+ **Passo 1:** Crea una cartella `tests` nel tuo progetto
26
+
27
+ **Passo 2:** Aggiungi i tuoi file di test con estensione `.spec.ts`
28
+
29
+ ```
30
+ your-project/
31
+ ├── tests/ # ← Crea solo questa cartella!
32
+ │ ├── example.spec.ts
33
+ │ ├── login.spec.ts
34
+ │ └── checkout.spec.ts
35
+ └── package.json
36
+ ```
37
+
38
+ **NOTA:** NON serve creare `playwright.config.ts` - la libreria include già la configurazione!
39
+
40
+ ### 2. Web UI (Interfaccia Grafica - NUOVO!) 🎨
41
+
42
+ **Il modo più semplice - interfaccia web completa:**
43
+
44
+ ```bash
45
+ npx playwright-ui
46
+ ```
47
+
48
+ Poi apri il browser su **http://localhost:3001**
49
+
50
+ Interfaccia grafica che permette di:
51
+ - 📋 Vedere tutti i test disponibili
52
+ - ▶️ Eseguire i test con un click
53
+ - 📊 Visualizzare il report interattivo
54
+ - ⚙️ Configurare reporter e opzioni
55
+
56
+ ### 3. Uso tramite CLI (Metodo Rapido)
57
+
58
+ **Esegui test e visualizza report automaticamente:**
59
+
60
+ ```bash
61
+ npx playwright-test
62
+ ```
63
+
64
+ Questo comando:
65
+ 1. ✅ Legge automaticamente i test dalla cartella `tests` del tuo progetto
66
+ 2. ✅ Esegue tutti i test Playwright
67
+ 3. ✅ Apre automaticamente il report UI nel browser
68
+
69
+ Opzioni disponibili:
70
+
71
+ ```bash
72
+ npx playwright-test --tests-dir e2e # Usa cartella 'e2e' invece di 'tests'
73
+ npx playwright-test --project /path/to/dir # Specifica root del progetto
74
+ npx playwright-test --help # Mostra help
75
+ ```
76
+
77
+ ### 4. Uso tramite Server API
78
+
79
+ Avvia il server dalla root del tuo progetto:
80
+
81
+ ```bash
82
+ npx playwright-runner
83
+ ```
84
+
85
+ Opzioni disponibili:
86
+
87
+ ```bash
88
+ npx playwright-runner --port 4000 # Usa porta 4000
89
+ npx playwright-runner --project /path/to/project # Specifica root del progetto
90
+ npx playwright-runner --tests-dir e2e # Usa cartella 'e2e' invece di 'tests'
91
+ ```
92
+
93
+ ### 5. Uso programmatico
94
+
95
+ Crea un file `test-server.ts` nel tuo progetto:
96
+
97
+ ```typescript
98
+ import { createServer } from '@playwright-test-runner/core';
99
+
100
+ const server = createServer({
101
+ port: 3000,
102
+ projectRoot: process.cwd(),
103
+ testsDir: 'tests'
104
+ });
105
+
106
+ server.start();
107
+ ```
108
+
109
+ ### 4. Uso come modulo
110
+
111
+ ```typescript
112
+ import { PlaywrightTestRunner } from '@playwright-test-runner/core';
113
+
114
+ async function runMyTests() {
115
+ const runner = new PlaywrightTestRunner({
116
+ projectRoot: process.cwd(),
117
+ testsDir: 'tests'
118
+ });
119
+
120
+ // Ottieni lista dei test
121
+ const testFiles = await runner.getTestFiles();
122
+ console.log('Test trovati:', testFiles);
123
+
124
+ // Esegui i test
125
+ const result = await runner.runTests({
126
+ reporter: 'html',
127
+ headed: false
128
+ });
129
+
130
+ console.log('Risultato:', result);
131
+ }
132
+
133
+ runMyTests();
134
+ ```
135
+
136
+ ## API Endpoints
137
+
138
+ Una volta avviato il server, saranno disponibili i seguenti endpoint:
139
+
140
+ ### GET /health
141
+
142
+ Health check del server.
143
+
144
+ **Response:**
145
+ ```json
146
+ {
147
+ "status": "ok",
148
+ "service": "playwright-test-runner"
149
+ }
150
+ ```
151
+
152
+ ### GET /tests
153
+
154
+ Ottieni la lista dei file di test disponibili.
155
+
156
+ **Response:**
157
+ ```json
158
+ {
159
+ "success": true,
160
+ "count": 3,
161
+ "files": [
162
+ "/path/to/project/tests/example.spec.ts",
163
+ "/path/to/project/tests/login.spec.ts",
164
+ "/path/to/project/tests/checkout.spec.ts"
165
+ ]
166
+ }
167
+ ```
168
+
169
+ ### POST /run
170
+
171
+ Esegui i test Playwright.
172
+
173
+ **Request Body:**
174
+ ```json
175
+ {
176
+ "reporter": "html",
177
+ "headed": false
178
+ }
179
+ ```
180
+
181
+ **Response:**
182
+ ```json
183
+ {
184
+ "success": true,
185
+ "output": "Running 3 tests...\n...",
186
+ "reportPath": "/path/to/project/playwright-report"
187
+ }
188
+ ```
189
+
190
+ ### POST /report/show
191
+
192
+ Avvia il server del report UI di Playwright.
193
+
194
+ **Response:**
195
+ ```json
196
+ {
197
+ "success": true,
198
+ "message": "Report UI avviato",
199
+ "url": "http://localhost:9323"
200
+ }
201
+ ```
202
+
203
+ ### POST /report/stop
204
+
205
+ Ferma il server del report UI.
206
+
207
+ **Response:**
208
+ ```json
209
+ {
210
+ "success": true,
211
+ "message": "Report UI fermato"
212
+ }
213
+ ```
214
+
215
+ ## Esempio di Test
216
+
217
+ Crea un file `tests/example.spec.ts`:
218
+
219
+ ```typescript
220
+ import { test, expect } from '@playwright/test';
221
+
222
+ test('homepage has title', async ({ page }) => {
223
+ await page.goto('https://playwright.dev/');
224
+ await expect(page).toHaveTitle(/Playwright/);
225
+ });
226
+
227
+ test('get started link', async ({ page }) => {
228
+ await page.goto('https://playwright.dev/');
229
+ await page.getByRole('link', { name: 'Get started' }).click();
230
+ await expect(page).toHaveURL(/.*intro/);
231
+ });
232
+ ```
233
+
234
+ ## Configurazione Playwright
235
+
236
+ Crea un file `playwright.config.ts` nella root del tuo progetto:
237
+
238
+ ```typescript
239
+ import { defineConfig, devices } from '@playwright/test';
240
+
241
+ export default defineConfig({
242
+ testDir: './tests',
243
+ fullyParallel: true,
244
+ forbidOnly: !!process.env.CI,
245
+ retries: process.env.CI ? 2 : 0,
246
+ workers: process.env.CI ? 1 : undefined,
247
+ reporter: 'html',
248
+ use: {
249
+ baseURL: 'http://localhost:3000',
250
+ trace: 'on-first-retry',
251
+ },
252
+ projects: [
253
+ {
254
+ name: 'chromium',
255
+ use: { ...devices['Desktop Chrome'] },
256
+ },
257
+ {
258
+ name: 'firefox',
259
+ use: { ...devices['Desktop Firefox'] },
260
+ },
261
+ {
262
+ name: 'webkit',
263
+ use: { ...devices['Desktop Safari'] },
264
+ },
265
+ ],
266
+ });
267
+ ```
268
+
269
+ ## Workflow Completo
270
+
271
+ 1. Installa la libreria nel tuo progetto
272
+ 2. Crea la cartella `tests` con i tuoi file `.spec.ts`
273
+ 3. Avvia il server: `npx playwright-runner`
274
+ 4. Esegui i test via API: `POST http://localhost:3000/run`
275
+ 5. Visualizza il report: `POST http://localhost:3000/report/show`
276
+ 6. Apri il browser su `http://localhost:9323` per vedere il report UI
277
+
278
+ ## Esempio con cURL
279
+
280
+ ```bash
281
+ # Health check
282
+ curl http://localhost:3000/health
283
+
284
+ # Lista test
285
+ curl http://localhost:3000/tests
286
+
287
+ # Esegui test
288
+ curl -X POST http://localhost:3000/run \
289
+ -H "Content-Type: application/json" \
290
+ -d '{"reporter":"html","headed":false}'
291
+
292
+ # Mostra report UI
293
+ curl -X POST http://localhost:3000/report/show
294
+
295
+ # Ferma report UI
296
+ curl -X POST http://localhost:3000/report/stop
297
+ ```
298
+
299
+ ## Script package.json consigliati
300
+
301
+ Aggiungi questi script al `package.json` del tuo progetto:
302
+
303
+ ```json
304
+ {
305
+ "scripts": {
306
+ "test:server": "playwright-runner",
307
+ "test:run": "playwright test",
308
+ "test:report": "playwright show-report"
309
+ }
310
+ }
311
+ ```
312
+
313
+ ## Requisiti
314
+
315
+ - Node.js >= 18
316
+ - TypeScript >= 5.0 (per progetti TypeScript)
317
+ - Playwright >= 1.40
318
+
319
+ ## License
320
+
321
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const server_1 = require("./server");
5
+ const args = process.argv.slice(2);
6
+ function parseArgs() {
7
+ // Usa INIT_CWD (directory da cui npm/npx è stato chiamato) invece di cwd
8
+ const options = {
9
+ port: 3000,
10
+ projectRoot: process.env.INIT_CWD || process.cwd(),
11
+ testsDir: 'tests',
12
+ };
13
+ for (let i = 0; i < args.length; i++) {
14
+ switch (args[i]) {
15
+ case '--port':
16
+ case '-p':
17
+ options.port = Number(args[++i]);
18
+ break;
19
+ case '--project':
20
+ case '-r':
21
+ options.projectRoot = args[++i];
22
+ break;
23
+ case '--tests-dir':
24
+ case '-t':
25
+ options.testsDir = args[++i];
26
+ break;
27
+ case '--help':
28
+ case '-h':
29
+ console.log(`
30
+ Playwright Test Runner - Server CLI
31
+
32
+ Usage:
33
+ playwright-runner [options]
34
+
35
+ Options:
36
+ -p, --port <port> Porta del server (default: 3000)
37
+ -r, --project <path> Root del progetto (default: current directory)
38
+ -t, --tests-dir <dir> Cartella dei test (default: tests)
39
+ -h, --help Mostra questo messaggio
40
+
41
+ Esempi:
42
+ playwright-runner
43
+ playwright-runner --port 4000
44
+ playwright-runner --project /path/to/project --tests-dir e2e
45
+ `);
46
+ process.exit(0);
47
+ }
48
+ }
49
+ return options;
50
+ }
51
+ const options = parseArgs();
52
+ const server = new server_1.PlaywrightServer(options);
53
+ server.start();
54
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,qCAA4C;AAE5C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,SAAS,SAAS;IAChB,yEAAyE;IACzE,MAAM,OAAO,GAAQ;QACnB,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,EAAE;QAClD,QAAQ,EAAE,OAAO;KAClB,CAAC;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,KAAK,QAAQ,CAAC;YACd,KAAK,IAAI;gBACP,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACjC,MAAM;YACR,KAAK,WAAW,CAAC;YACjB,KAAK,IAAI;gBACP,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;gBAChC,MAAM;YACR,KAAK,aAAa,CAAC;YACnB,KAAK,IAAI;gBACP,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC7B,MAAM;YACR,KAAK,QAAQ,CAAC;YACd,KAAK,IAAI;gBACP,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;SAgBX,CAAC,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;AAC5B,MAAM,MAAM,GAAG,IAAI,yBAAgB,CAAC,OAAO,CAAC,CAAC;AAC7C,MAAM,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { PlaywrightServer } from './server';
2
+ import { PlaywrightTestRunner } from './test-runner';
3
+ import { runAndShow } from './run-and-show';
4
+ import { PlaywrightWebUI } from './web-ui';
5
+ export { PlaywrightServer, PlaywrightTestRunner, runAndShow, PlaywrightWebUI };
6
+ export * from './test-runner';
7
+ export * from './server';
8
+ export * from './run-and-show';
9
+ export * from './web-ui';
10
+ export declare function createServer(options?: {}): PlaywrightServer;
11
+ export declare function createTestRunner(options?: {}): PlaywrightTestRunner;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;AAC/E,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AAEzB,wBAAgB,YAAY,CAAC,OAAO,KAAK,oBAExC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,KAAK,wBAE5C"}
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.PlaywrightWebUI = exports.runAndShow = exports.PlaywrightTestRunner = exports.PlaywrightServer = void 0;
18
+ exports.createServer = createServer;
19
+ exports.createTestRunner = createTestRunner;
20
+ const server_1 = require("./server");
21
+ Object.defineProperty(exports, "PlaywrightServer", { enumerable: true, get: function () { return server_1.PlaywrightServer; } });
22
+ const test_runner_1 = require("./test-runner");
23
+ Object.defineProperty(exports, "PlaywrightTestRunner", { enumerable: true, get: function () { return test_runner_1.PlaywrightTestRunner; } });
24
+ const run_and_show_1 = require("./run-and-show");
25
+ Object.defineProperty(exports, "runAndShow", { enumerable: true, get: function () { return run_and_show_1.runAndShow; } });
26
+ const web_ui_1 = require("./web-ui");
27
+ Object.defineProperty(exports, "PlaywrightWebUI", { enumerable: true, get: function () { return web_ui_1.PlaywrightWebUI; } });
28
+ __exportStar(require("./test-runner"), exports);
29
+ __exportStar(require("./server"), exports);
30
+ __exportStar(require("./run-and-show"), exports);
31
+ __exportStar(require("./web-ui"), exports);
32
+ function createServer(options = {}) {
33
+ return new server_1.PlaywrightServer(options);
34
+ }
35
+ function createTestRunner(options = {}) {
36
+ return new test_runner_1.PlaywrightTestRunner(options);
37
+ }
38
+ if (require.main === module) {
39
+ const server = new server_1.PlaywrightServer({
40
+ port: Number(process.env.PORT) || 3000,
41
+ projectRoot: process.env.PROJECT_ROOT || process.cwd(),
42
+ testsDir: process.env.TESTS_DIR || 'tests',
43
+ });
44
+ server.start();
45
+ }
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAWA,oCAEC;AAED,4CAEC;AAjBD,qCAA4C;AAKnC,iGALA,yBAAgB,OAKA;AAJzB,+CAAqD;AAI1B,qGAJlB,kCAAoB,OAIkB;AAH/C,iDAA4C;AAGK,2FAHxC,yBAAU,OAGwC;AAF3D,qCAA2C;AAEkB,gGAFpD,wBAAe,OAEoD;AAC5E,gDAA8B;AAC9B,2CAAyB;AACzB,iDAA+B;AAC/B,2CAAyB;AAEzB,SAAgB,YAAY,CAAC,OAAO,GAAG,EAAE;IACvC,OAAO,IAAI,yBAAgB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC;AAED,SAAgB,gBAAgB,CAAC,OAAO,GAAG,EAAE;IAC3C,OAAO,IAAI,kCAAoB,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,yBAAgB,CAAC;QAClC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI;QACtC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,EAAE;QACtD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,OAAO;KAC3C,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,EAAE,CAAC;AACjB,CAAC"}
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Comando semplice che:
4
+ * 1. Legge i test dalla cartella del progetto consumer
5
+ * 2. Esegue i test
6
+ * 3. Mostra automaticamente il report UI
7
+ */
8
+ declare function runAndShow(): Promise<void>;
9
+ export { runAndShow };
10
+ //# sourceMappingURL=run-and-show.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-and-show.d.ts","sourceRoot":"","sources":["../src/run-and-show.ts"],"names":[],"mappings":";AAKA;;;;;GAKG;AAEH,iBAAe,UAAU,kBAyHxB;AAUD,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,158 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.runAndShow = runAndShow;
38
+ const test_runner_1 = require("./test-runner");
39
+ const path = __importStar(require("path"));
40
+ /**
41
+ * Comando semplice che:
42
+ * 1. Legge i test dalla cartella del progetto consumer
43
+ * 2. Esegue i test
44
+ * 3. Mostra automaticamente il report UI
45
+ */
46
+ async function runAndShow() {
47
+ const args = process.argv.slice(2);
48
+ // Parse arguments
49
+ let testsDir = 'tests';
50
+ // Usa INIT_CWD (directory da cui npm/npx è stato chiamato) invece di cwd
51
+ let projectRoot = process.env.INIT_CWD || process.cwd();
52
+ for (let i = 0; i < args.length; i++) {
53
+ switch (args[i]) {
54
+ case '--tests-dir':
55
+ case '-t':
56
+ testsDir = args[++i];
57
+ break;
58
+ case '--project':
59
+ case '-p':
60
+ projectRoot = args[++i];
61
+ break;
62
+ case '--help':
63
+ case '-h':
64
+ console.log(`
65
+ Playwright Test Runner - Run and Show Report
66
+
67
+ Usage:
68
+ npx playwright-test [options]
69
+
70
+ Options:
71
+ -t, --tests-dir <dir> Cartella dei test (default: tests)
72
+ -p, --project <path> Root del progetto (default: current directory)
73
+ -h, --help Mostra questo messaggio
74
+
75
+ Esempio:
76
+ npx playwright-test
77
+ npx playwright-test --tests-dir e2e
78
+ npx playwright-test --project /path/to/project
79
+
80
+ Questo comando:
81
+ 1. Cerca i file *.spec.ts nella cartella specificata
82
+ 2. Esegue tutti i test con Playwright
83
+ 3. Mostra automaticamente il report UI nel browser
84
+ `);
85
+ process.exit(0);
86
+ }
87
+ }
88
+ console.log('🎭 Playwright Test Runner\n');
89
+ console.log(`📁 Progetto: ${projectRoot}`);
90
+ console.log(`📂 Cartella test: ${testsDir}\n`);
91
+ const runner = new test_runner_1.PlaywrightTestRunner({
92
+ projectRoot,
93
+ testsDir,
94
+ });
95
+ try {
96
+ // Step 1: Trova i test
97
+ console.log('🔍 Ricerca file di test...');
98
+ const testFiles = await runner.getTestFiles();
99
+ if (testFiles.length === 0) {
100
+ console.error(`\n❌ Nessun file di test trovato in ${path.join(projectRoot, testsDir)}`);
101
+ console.error('\nAssicurati che:');
102
+ console.error(' - La cartella esista');
103
+ console.error(' - Ci siano file con estensione .spec.ts o .spec.js');
104
+ process.exit(1);
105
+ }
106
+ console.log(`✅ Trovati ${testFiles.length} file di test:\n`);
107
+ testFiles.forEach(file => {
108
+ const relativePath = path.relative(projectRoot, file);
109
+ console.log(` • ${relativePath}`);
110
+ });
111
+ // Step 2: Esegui i test
112
+ console.log('\n⚡ Esecuzione test in corso...\n');
113
+ console.log('━'.repeat(50));
114
+ const result = await runner.runTests({
115
+ reporter: 'html',
116
+ headed: false,
117
+ });
118
+ console.log('━'.repeat(50));
119
+ if (!result.success) {
120
+ console.error('\n❌ Test falliti!\n');
121
+ if (result.error) {
122
+ console.error('Errore:', result.error);
123
+ }
124
+ if (result.output) {
125
+ console.log('\nOutput:\n', result.output);
126
+ }
127
+ console.log('\n💡 Prova a visualizzare il report per più dettagli:');
128
+ console.log(' npx playwright show-report');
129
+ process.exit(1);
130
+ }
131
+ console.log('\n✅ Test completati con successo!\n');
132
+ // Step 3: Mostra il report
133
+ console.log('📊 Avvio report UI...\n');
134
+ const { url } = await runner.showReport();
135
+ console.log('━'.repeat(50));
136
+ console.log(`\n✨ Report disponibile su: ${url}`);
137
+ console.log('\n💡 Il report si aprirà automaticamente nel browser');
138
+ console.log(' Premi Ctrl+C per chiudere il report e uscire\n');
139
+ console.log('━'.repeat(50));
140
+ // Mantieni il processo attivo
141
+ process.on('SIGINT', () => {
142
+ console.log('\n\n👋 Chiusura report...');
143
+ process.exit(0);
144
+ });
145
+ }
146
+ catch (error) {
147
+ console.error('\n❌ Errore:', error.message);
148
+ process.exit(1);
149
+ }
150
+ }
151
+ // Esegui solo se chiamato direttamente
152
+ if (require.main === module) {
153
+ runAndShow().catch(error => {
154
+ console.error('Errore fatale:', error);
155
+ process.exit(1);
156
+ });
157
+ }
158
+ //# sourceMappingURL=run-and-show.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-and-show.js","sourceRoot":"","sources":["../src/run-and-show.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+IS,gCAAU;AA7InB,+CAAqD;AACrD,2CAA6B;AAE7B;;;;;GAKG;AAEH,KAAK,UAAU,UAAU;IACvB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,kBAAkB;IAClB,IAAI,QAAQ,GAAG,OAAO,CAAC;IACvB,yEAAyE;IACzE,IAAI,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAExD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,KAAK,aAAa,CAAC;YACnB,KAAK,IAAI;gBACP,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,CAA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,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;QACjD,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;QACpE,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QACjE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAE5B,8BAA8B;QAC9B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACxB,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IAEL,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,uCAAuC;AACvC,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,UAAU,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACzB,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,18 @@
1
+ import express from 'express';
2
+ export interface ServerOptions {
3
+ port?: number;
4
+ projectRoot?: string;
5
+ testsDir?: string;
6
+ }
7
+ export declare class PlaywrightServer {
8
+ private app;
9
+ private port;
10
+ private testRunner;
11
+ private reportProcess;
12
+ constructor(options?: ServerOptions);
13
+ private setupMiddleware;
14
+ private setupRoutes;
15
+ start(): void;
16
+ getApp(): express.Application;
17
+ }
18
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,OAA8B,MAAM,SAAS,CAAC;AAIrD,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,GAAG,CAAsB;IACjC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,aAAa,CAAa;gBAEtB,OAAO,GAAE,aAAkB;IAYvC,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,WAAW;IAuFZ,KAAK,IAAI,IAAI;IAYb,MAAM,IAAI,OAAO,CAAC,WAAW;CAGrC"}