@playwright-test-runner/core 1.0.0 → 1.0.2
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 +18 -36
- package/dist/daemon-cli.d.ts +3 -0
- package/dist/daemon-cli.d.ts.map +1 -0
- package/dist/daemon-cli.js +149 -0
- package/dist/daemon-cli.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/report-daemon.d.ts +26 -0
- package/dist/report-daemon.d.ts.map +1 -0
- package/dist/report-daemon.js +409 -0
- package/dist/report-daemon.js.map +1 -0
- package/dist/run-and-show.d.ts.map +1 -1
- package/dist/run-and-show.js +7 -4
- package/dist/run-and-show.js.map +1 -1
- package/dist/test-runner.d.ts +9 -0
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +59 -2
- package/dist/test-runner.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -231,41 +231,6 @@ test('get started link', async ({ page }) => {
|
|
|
231
231
|
});
|
|
232
232
|
```
|
|
233
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
234
|
## Workflow Completo
|
|
270
235
|
|
|
271
236
|
1. Installa la libreria nel tuo progetto
|
|
@@ -310,11 +275,28 @@ Aggiungi questi script al `package.json` del tuo progetto:
|
|
|
310
275
|
}
|
|
311
276
|
```
|
|
312
277
|
|
|
278
|
+
## Troubleshooting
|
|
279
|
+
|
|
280
|
+
Hai problemi? Consulta la [Guida al Troubleshooting](TROUBLESHOOTING.md) per risolvere i problemi più comuni:
|
|
281
|
+
|
|
282
|
+
- ❌ Errore "porta 9323 già in uso" → [Soluzione](TROUBLESHOOTING.md#errore-listen-eaddrinuse-address-already-in-use-19323)
|
|
283
|
+
- ❌ Errore "cartella tests non trovata" → [Soluzione](TROUBLESHOOTING.md#errore-cartella-tests-non-trovata)
|
|
284
|
+
- ❌ Errore "playwright: command not found" → [Soluzione](TROUBLESHOOTING.md#errore-playwright-command-not-found)
|
|
285
|
+
- E molti altri...
|
|
286
|
+
|
|
287
|
+
## Guide Aggiuntive
|
|
288
|
+
|
|
289
|
+
- 📖 [QUICKSTART.md](QUICKSTART.md) - Guida rapida per iniziare
|
|
290
|
+
- 🔧 [SETUP_SEMPLIFICATO.md](SETUP_SEMPLIFICATO.md) - Setup zero-config
|
|
291
|
+
- 🌐 [WEB_UI_GUIDE.md](WEB_UI_GUIDE.md) - Guida all'interfaccia Web
|
|
292
|
+
- 🔗 [INTEGRATION.md](INTEGRATION.md) - Integrazione con framework (React, Vue, Angular, ecc.)
|
|
293
|
+
- 🧪 [LOCAL_TESTING_GUIDE.md](LOCAL_TESTING_GUIDE.md) - Testing locale con npm link
|
|
294
|
+
|
|
313
295
|
## Requisiti
|
|
314
296
|
|
|
315
297
|
- Node.js >= 18
|
|
316
298
|
- TypeScript >= 5.0 (per progetti TypeScript)
|
|
317
|
-
- Playwright
|
|
299
|
+
- **Playwright è incluso nella libreria** - NON serve installarlo!
|
|
318
300
|
|
|
319
301
|
## License
|
|
320
302
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon-cli.d.ts","sourceRoot":"","sources":["../src/daemon-cli.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,149 @@
|
|
|
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
|
+
const report_daemon_1 = require("./report-daemon");
|
|
38
|
+
const child_process_1 = require("child_process");
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const args = process.argv.slice(2);
|
|
41
|
+
const command = args[0];
|
|
42
|
+
function parseArgs() {
|
|
43
|
+
const options = {
|
|
44
|
+
port: 9324,
|
|
45
|
+
projectRoot: process.env.INIT_CWD || process.cwd(),
|
|
46
|
+
testsDir: 'tests',
|
|
47
|
+
};
|
|
48
|
+
for (let i = 0; i < args.length; i++) {
|
|
49
|
+
switch (args[i]) {
|
|
50
|
+
case '--port':
|
|
51
|
+
case '-p':
|
|
52
|
+
options.port = Number(args[++i]);
|
|
53
|
+
break;
|
|
54
|
+
case '--project':
|
|
55
|
+
case '-r':
|
|
56
|
+
options.projectRoot = args[++i];
|
|
57
|
+
break;
|
|
58
|
+
case '--tests-dir':
|
|
59
|
+
case '-t':
|
|
60
|
+
options.testsDir = args[++i];
|
|
61
|
+
break;
|
|
62
|
+
case '--help':
|
|
63
|
+
case '-h':
|
|
64
|
+
console.log(`
|
|
65
|
+
Playwright Report Daemon - Server Persistente per Report
|
|
66
|
+
|
|
67
|
+
Usage:
|
|
68
|
+
playwright-daemon [command] [options]
|
|
69
|
+
|
|
70
|
+
Commands:
|
|
71
|
+
start Avvia il daemon (default)
|
|
72
|
+
stop Ferma il daemon
|
|
73
|
+
status Controlla lo stato del daemon
|
|
74
|
+
|
|
75
|
+
Options:
|
|
76
|
+
-p, --port <port> Porta del server (default: 9324)
|
|
77
|
+
-r, --project <path> Root del progetto (default: current directory)
|
|
78
|
+
-t, --tests-dir <dir> Cartella dei test (default: tests)
|
|
79
|
+
-h, --help Mostra questo messaggio
|
|
80
|
+
|
|
81
|
+
Esempi:
|
|
82
|
+
playwright-daemon # Avvia il daemon
|
|
83
|
+
playwright-daemon start --port 9000 # Avvia su porta custom
|
|
84
|
+
playwright-daemon stop # Ferma il daemon
|
|
85
|
+
playwright-daemon status # Controlla stato
|
|
86
|
+
|
|
87
|
+
Controllo Automatico all'Installazione:
|
|
88
|
+
• NODE_ENV=production → Daemon NON avviato
|
|
89
|
+
• CI=true → Daemon NON avviato
|
|
90
|
+
• PLAYWRIGHT_SKIP_DAEMON=true → Skip completamente
|
|
91
|
+
• PLAYWRIGHT_DAEMON_AUTO=false → Avvio manuale richiesto
|
|
92
|
+
|
|
93
|
+
Il server servirà i report su:
|
|
94
|
+
http://localhost:9324 (o la porta specificata)
|
|
95
|
+
`);
|
|
96
|
+
process.exit(0);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return options;
|
|
100
|
+
}
|
|
101
|
+
async function main() {
|
|
102
|
+
// Gestisci subcomandi
|
|
103
|
+
if (command === 'stop') {
|
|
104
|
+
const stopScript = path.join(__dirname, '../scripts/stop-daemon.js');
|
|
105
|
+
(0, child_process_1.exec)(`node "${stopScript}"`, (error, stdout, stderr) => {
|
|
106
|
+
if (stdout)
|
|
107
|
+
console.log(stdout);
|
|
108
|
+
if (stderr)
|
|
109
|
+
console.error(stderr);
|
|
110
|
+
if (error)
|
|
111
|
+
process.exit(1);
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (command === 'status') {
|
|
116
|
+
const statusScript = path.join(__dirname, '../scripts/status-daemon.js');
|
|
117
|
+
(0, child_process_1.exec)(`node "${statusScript}"`, (error, stdout, stderr) => {
|
|
118
|
+
if (stdout)
|
|
119
|
+
console.log(stdout);
|
|
120
|
+
if (stderr)
|
|
121
|
+
console.error(stderr);
|
|
122
|
+
if (error)
|
|
123
|
+
process.exit(1);
|
|
124
|
+
});
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
// Comando start (default)
|
|
128
|
+
const options = parseArgs();
|
|
129
|
+
const daemon = new report_daemon_1.ReportDaemon(options);
|
|
130
|
+
try {
|
|
131
|
+
await daemon.start();
|
|
132
|
+
// Graceful shutdown
|
|
133
|
+
const cleanup = () => {
|
|
134
|
+
console.log('\n\n👋 Arresto server...');
|
|
135
|
+
daemon.stop();
|
|
136
|
+
process.exit(0);
|
|
137
|
+
};
|
|
138
|
+
process.on('SIGINT', cleanup);
|
|
139
|
+
process.on('SIGTERM', cleanup);
|
|
140
|
+
// Mantieni il processo attivo
|
|
141
|
+
process.stdin.resume();
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
console.error('❌ Errore durante l\'avvio del daemon:', error.message);
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
main();
|
|
149
|
+
//# sourceMappingURL=daemon-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon-cli.js","sourceRoot":"","sources":["../src/daemon-cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,mDAA+C;AAC/C,iDAAqC;AACrC,2CAA6B;AAE7B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAExB,SAAS,SAAS;IAChB,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,C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ANGED
|
@@ -2,11 +2,14 @@ import { PlaywrightServer } from './server';
|
|
|
2
2
|
import { PlaywrightTestRunner } from './test-runner';
|
|
3
3
|
import { runAndShow } from './run-and-show';
|
|
4
4
|
import { PlaywrightWebUI } from './web-ui';
|
|
5
|
-
|
|
5
|
+
import { ReportDaemon } from './report-daemon';
|
|
6
|
+
export { PlaywrightServer, PlaywrightTestRunner, runAndShow, PlaywrightWebUI, ReportDaemon };
|
|
6
7
|
export * from './test-runner';
|
|
7
8
|
export * from './server';
|
|
8
9
|
export * from './run-and-show';
|
|
9
10
|
export * from './web-ui';
|
|
11
|
+
export * from './report-daemon';
|
|
10
12
|
export declare function createServer(options?: {}): PlaywrightServer;
|
|
11
13
|
export declare function createTestRunner(options?: {}): PlaywrightTestRunner;
|
|
14
|
+
export declare function createDaemon(options?: {}): ReportDaemon;
|
|
12
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC;AAC7F,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAEhC,wBAAgB,YAAY,CAAC,OAAO,KAAK,oBAExC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,KAAK,wBAE5C;AAED,wBAAgB,YAAY,CAAC,OAAO,KAAK,gBAExC"}
|
package/dist/index.js
CHANGED
|
@@ -14,9 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.PlaywrightWebUI = exports.runAndShow = exports.PlaywrightTestRunner = exports.PlaywrightServer = void 0;
|
|
17
|
+
exports.ReportDaemon = exports.PlaywrightWebUI = exports.runAndShow = exports.PlaywrightTestRunner = exports.PlaywrightServer = void 0;
|
|
18
18
|
exports.createServer = createServer;
|
|
19
19
|
exports.createTestRunner = createTestRunner;
|
|
20
|
+
exports.createDaemon = createDaemon;
|
|
20
21
|
const server_1 = require("./server");
|
|
21
22
|
Object.defineProperty(exports, "PlaywrightServer", { enumerable: true, get: function () { return server_1.PlaywrightServer; } });
|
|
22
23
|
const test_runner_1 = require("./test-runner");
|
|
@@ -25,16 +26,22 @@ const run_and_show_1 = require("./run-and-show");
|
|
|
25
26
|
Object.defineProperty(exports, "runAndShow", { enumerable: true, get: function () { return run_and_show_1.runAndShow; } });
|
|
26
27
|
const web_ui_1 = require("./web-ui");
|
|
27
28
|
Object.defineProperty(exports, "PlaywrightWebUI", { enumerable: true, get: function () { return web_ui_1.PlaywrightWebUI; } });
|
|
29
|
+
const report_daemon_1 = require("./report-daemon");
|
|
30
|
+
Object.defineProperty(exports, "ReportDaemon", { enumerable: true, get: function () { return report_daemon_1.ReportDaemon; } });
|
|
28
31
|
__exportStar(require("./test-runner"), exports);
|
|
29
32
|
__exportStar(require("./server"), exports);
|
|
30
33
|
__exportStar(require("./run-and-show"), exports);
|
|
31
34
|
__exportStar(require("./web-ui"), exports);
|
|
35
|
+
__exportStar(require("./report-daemon"), exports);
|
|
32
36
|
function createServer(options = {}) {
|
|
33
37
|
return new server_1.PlaywrightServer(options);
|
|
34
38
|
}
|
|
35
39
|
function createTestRunner(options = {}) {
|
|
36
40
|
return new test_runner_1.PlaywrightTestRunner(options);
|
|
37
41
|
}
|
|
42
|
+
function createDaemon(options = {}) {
|
|
43
|
+
return new report_daemon_1.ReportDaemon(options);
|
|
44
|
+
}
|
|
38
45
|
if (require.main === module) {
|
|
39
46
|
const server = new server_1.PlaywrightServer({
|
|
40
47
|
port: Number(process.env.PORT) || 3000,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAaA,oCAEC;AAED,4CAEC;AAED,oCAEC;AAvBD,qCAA4C;AAMnC,iGANA,yBAAgB,OAMA;AALzB,+CAAqD;AAK1B,qGALlB,kCAAoB,OAKkB;AAJ/C,iDAA4C;AAIK,2FAJxC,yBAAU,OAIwC;AAH3D,qCAA2C;AAGkB,gGAHpD,wBAAe,OAGoD;AAF5E,mDAA+C;AAE+B,6FAFrE,4BAAY,OAEqE;AAC1F,gDAA8B;AAC9B,2CAAyB;AACzB,iDAA+B;AAC/B,2CAAyB;AACzB,kDAAgC;AAEhC,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,SAAgB,YAAY,CAAC,OAAO,GAAG,EAAE;IACvC,OAAO,IAAI,4BAAY,CAAC,OAAO,CAAC,CAAC;AACnC,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,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Report Daemon Server
|
|
4
|
+
* Server persistente che serve i report Playwright su una porta fissa
|
|
5
|
+
*/
|
|
6
|
+
export interface ReportDaemonOptions {
|
|
7
|
+
port?: number;
|
|
8
|
+
projectRoot?: string;
|
|
9
|
+
testsDir?: string;
|
|
10
|
+
autoStart?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class ReportDaemon {
|
|
13
|
+
private app;
|
|
14
|
+
private runner;
|
|
15
|
+
private port;
|
|
16
|
+
private projectRoot;
|
|
17
|
+
private testsDir;
|
|
18
|
+
private server;
|
|
19
|
+
constructor(options?: ReportDaemonOptions);
|
|
20
|
+
private setupMiddleware;
|
|
21
|
+
private setupRoutes;
|
|
22
|
+
start(): Promise<void>;
|
|
23
|
+
stop(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare function createDaemon(options?: ReportDaemonOptions): ReportDaemon;
|
|
26
|
+
//# sourceMappingURL=report-daemon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-daemon.d.ts","sourceRoot":"","sources":["../src/report-daemon.ts"],"names":[],"mappings":";AAQA;;;GAGG;AAEH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,GAAG,CAAsB;IACjC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAa;gBAEf,OAAO,GAAE,mBAAwB;IAe7C,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,WAAW;IAmSb,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAyC5B,IAAI,IAAI,IAAI;CAMb;AAGD,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,gBAE7D"}
|
|
@@ -0,0 +1,409 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.ReportDaemon = void 0;
|
|
41
|
+
exports.createDaemon = createDaemon;
|
|
42
|
+
const express_1 = __importDefault(require("express"));
|
|
43
|
+
const test_runner_1 = require("./test-runner");
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const fs = __importStar(require("fs/promises"));
|
|
46
|
+
const cors_1 = __importDefault(require("cors"));
|
|
47
|
+
class ReportDaemon {
|
|
48
|
+
app;
|
|
49
|
+
runner;
|
|
50
|
+
port;
|
|
51
|
+
projectRoot;
|
|
52
|
+
testsDir;
|
|
53
|
+
server = null;
|
|
54
|
+
constructor(options = {}) {
|
|
55
|
+
this.port = options.port || 9324; // Porta fissa per il daemon
|
|
56
|
+
this.projectRoot = options.projectRoot || process.env.INIT_CWD || process.cwd();
|
|
57
|
+
this.testsDir = options.testsDir || 'tests';
|
|
58
|
+
this.app = (0, express_1.default)();
|
|
59
|
+
this.runner = new test_runner_1.PlaywrightTestRunner({
|
|
60
|
+
projectRoot: this.projectRoot,
|
|
61
|
+
testsDir: this.testsDir,
|
|
62
|
+
});
|
|
63
|
+
this.setupMiddleware();
|
|
64
|
+
this.setupRoutes();
|
|
65
|
+
}
|
|
66
|
+
setupMiddleware() {
|
|
67
|
+
this.app.use((0, cors_1.default)());
|
|
68
|
+
this.app.use(express_1.default.json());
|
|
69
|
+
this.app.use(express_1.default.static(path.join(__dirname, '../public')));
|
|
70
|
+
}
|
|
71
|
+
setupRoutes() {
|
|
72
|
+
// Health check
|
|
73
|
+
this.app.get('/health', (req, res) => {
|
|
74
|
+
res.json({
|
|
75
|
+
status: 'ok',
|
|
76
|
+
projectRoot: this.projectRoot,
|
|
77
|
+
testsDir: this.testsDir,
|
|
78
|
+
port: this.port,
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
// Serve il report direttamente sulla root
|
|
82
|
+
this.app.get('/', async (req, res) => {
|
|
83
|
+
const reportPath = path.join(this.projectRoot, 'playwright-report', 'index.html');
|
|
84
|
+
try {
|
|
85
|
+
await fs.access(reportPath);
|
|
86
|
+
// Serve l'intero folder playwright-report come statico
|
|
87
|
+
express_1.default.static(path.join(this.projectRoot, 'playwright-report'))(req, res, () => {
|
|
88
|
+
res.sendFile(reportPath);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
res.status(404).send(`
|
|
93
|
+
<!DOCTYPE html>
|
|
94
|
+
<html>
|
|
95
|
+
<head>
|
|
96
|
+
<title>Playwright Test Reports</title>
|
|
97
|
+
<style>
|
|
98
|
+
body {
|
|
99
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
100
|
+
max-width: 800px;
|
|
101
|
+
margin: 50px auto;
|
|
102
|
+
padding: 20px;
|
|
103
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
104
|
+
color: white;
|
|
105
|
+
}
|
|
106
|
+
.container {
|
|
107
|
+
background: rgba(255, 255, 255, 0.1);
|
|
108
|
+
backdrop-filter: blur(10px);
|
|
109
|
+
border-radius: 20px;
|
|
110
|
+
padding: 40px;
|
|
111
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
|
112
|
+
}
|
|
113
|
+
h1 { margin-top: 0; }
|
|
114
|
+
.btn {
|
|
115
|
+
display: inline-block;
|
|
116
|
+
background: white;
|
|
117
|
+
color: #667eea;
|
|
118
|
+
padding: 12px 24px;
|
|
119
|
+
border-radius: 8px;
|
|
120
|
+
text-decoration: none;
|
|
121
|
+
font-weight: 600;
|
|
122
|
+
margin: 10px 10px 10px 0;
|
|
123
|
+
transition: transform 0.2s;
|
|
124
|
+
}
|
|
125
|
+
.btn:hover {
|
|
126
|
+
transform: translateY(-2px);
|
|
127
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
128
|
+
}
|
|
129
|
+
.info {
|
|
130
|
+
background: rgba(255, 255, 255, 0.1);
|
|
131
|
+
padding: 20px;
|
|
132
|
+
border-radius: 10px;
|
|
133
|
+
margin: 20px 0;
|
|
134
|
+
}
|
|
135
|
+
code {
|
|
136
|
+
background: rgba(0, 0, 0, 0.3);
|
|
137
|
+
padding: 2px 8px;
|
|
138
|
+
border-radius: 4px;
|
|
139
|
+
font-family: 'Courier New', monospace;
|
|
140
|
+
}
|
|
141
|
+
</style>
|
|
142
|
+
</head>
|
|
143
|
+
<body>
|
|
144
|
+
<div class="container">
|
|
145
|
+
<h1>📊 Playwright Test Reports</h1>
|
|
146
|
+
<p>Nessun report disponibile al momento.</p>
|
|
147
|
+
|
|
148
|
+
<div class="info">
|
|
149
|
+
<h3>Come generare un report:</h3>
|
|
150
|
+
<ol>
|
|
151
|
+
<li>Esegui i test: <code>npx playwright-test</code></li>
|
|
152
|
+
<li>Oppure usa la Web UI: <code>npx playwright-ui</code></li>
|
|
153
|
+
<li>Oppure usa il comando run: <code>npm run test:e2e</code></li>
|
|
154
|
+
</ol>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
<div style="margin-top: 30px;">
|
|
158
|
+
<a href="/api/run" class="btn">🚀 Esegui Test Ora</a>
|
|
159
|
+
<a href="/dashboard" class="btn">📋 Dashboard</a>
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
<div style="margin-top: 30px; font-size: 14px; opacity: 0.8;">
|
|
163
|
+
<p><strong>Progetto:</strong> ${this.projectRoot}</p>
|
|
164
|
+
<p><strong>Test Directory:</strong> ${this.testsDir}</p>
|
|
165
|
+
<p><strong>Server attivo su:</strong> http://localhost:${this.port}</p>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
</body>
|
|
169
|
+
</html>
|
|
170
|
+
`);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
// Serve tutti gli asset del report
|
|
174
|
+
this.app.use('/data', express_1.default.static(path.join(this.projectRoot, 'playwright-report', 'data')));
|
|
175
|
+
this.app.use('/trace', express_1.default.static(path.join(this.projectRoot, 'playwright-report', 'trace')));
|
|
176
|
+
// API per eseguire i test
|
|
177
|
+
this.app.post('/api/run', async (req, res) => {
|
|
178
|
+
try {
|
|
179
|
+
console.log('🚀 Esecuzione test in corso...');
|
|
180
|
+
const result = await this.runner.runTests({
|
|
181
|
+
reporter: 'html',
|
|
182
|
+
headed: false,
|
|
183
|
+
...req.body,
|
|
184
|
+
});
|
|
185
|
+
res.json({
|
|
186
|
+
success: result.success,
|
|
187
|
+
output: result.output,
|
|
188
|
+
error: result.error,
|
|
189
|
+
reportUrl: `http://localhost:${this.port}`,
|
|
190
|
+
});
|
|
191
|
+
if (result.success) {
|
|
192
|
+
console.log(`✅ Test completati! Report disponibile su http://localhost:${this.port}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
console.error('❌ Errore durante l\'esecuzione dei test:', error.message);
|
|
197
|
+
res.status(500).json({
|
|
198
|
+
success: false,
|
|
199
|
+
error: error.message,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
// API per ottenere la lista dei test
|
|
204
|
+
this.app.get('/api/tests', async (req, res) => {
|
|
205
|
+
try {
|
|
206
|
+
const files = await this.runner.getTestFiles();
|
|
207
|
+
res.json({
|
|
208
|
+
success: true,
|
|
209
|
+
count: files.length,
|
|
210
|
+
files,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
res.status(500).json({
|
|
215
|
+
success: false,
|
|
216
|
+
error: error.message,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
// Dashboard per gestire i test
|
|
221
|
+
this.app.get('/dashboard', (req, res) => {
|
|
222
|
+
res.send(`
|
|
223
|
+
<!DOCTYPE html>
|
|
224
|
+
<html>
|
|
225
|
+
<head>
|
|
226
|
+
<title>Playwright Test Dashboard</title>
|
|
227
|
+
<style>
|
|
228
|
+
body {
|
|
229
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
230
|
+
max-width: 1000px;
|
|
231
|
+
margin: 0 auto;
|
|
232
|
+
padding: 20px;
|
|
233
|
+
background: #f5f5f5;
|
|
234
|
+
}
|
|
235
|
+
.header {
|
|
236
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
237
|
+
color: white;
|
|
238
|
+
padding: 30px;
|
|
239
|
+
border-radius: 10px;
|
|
240
|
+
margin-bottom: 20px;
|
|
241
|
+
}
|
|
242
|
+
.card {
|
|
243
|
+
background: white;
|
|
244
|
+
padding: 20px;
|
|
245
|
+
border-radius: 10px;
|
|
246
|
+
margin-bottom: 20px;
|
|
247
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
248
|
+
}
|
|
249
|
+
.btn {
|
|
250
|
+
background: #667eea;
|
|
251
|
+
color: white;
|
|
252
|
+
border: none;
|
|
253
|
+
padding: 12px 24px;
|
|
254
|
+
border-radius: 6px;
|
|
255
|
+
cursor: pointer;
|
|
256
|
+
font-size: 16px;
|
|
257
|
+
margin-right: 10px;
|
|
258
|
+
}
|
|
259
|
+
.btn:hover { background: #5568d3; }
|
|
260
|
+
.btn-success { background: #48bb78; }
|
|
261
|
+
.btn-success:hover { background: #38a169; }
|
|
262
|
+
#output {
|
|
263
|
+
background: #1a202c;
|
|
264
|
+
color: #e2e8f0;
|
|
265
|
+
padding: 20px;
|
|
266
|
+
border-radius: 6px;
|
|
267
|
+
font-family: 'Courier New', monospace;
|
|
268
|
+
white-space: pre-wrap;
|
|
269
|
+
max-height: 400px;
|
|
270
|
+
overflow-y: auto;
|
|
271
|
+
}
|
|
272
|
+
</style>
|
|
273
|
+
</head>
|
|
274
|
+
<body>
|
|
275
|
+
<div class="header">
|
|
276
|
+
<h1>📊 Playwright Test Dashboard</h1>
|
|
277
|
+
<p>Gestisci e visualizza i tuoi test E2E</p>
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
<div class="card">
|
|
281
|
+
<h2>⚡ Azioni Rapide</h2>
|
|
282
|
+
<button class="btn" onclick="runTests()">▶️ Esegui Tutti i Test</button>
|
|
283
|
+
<button class="btn btn-success" onclick="viewReport()">📊 Visualizza Report</button>
|
|
284
|
+
<button class="btn" onclick="getTestList()">📋 Lista Test</button>
|
|
285
|
+
</div>
|
|
286
|
+
|
|
287
|
+
<div class="card">
|
|
288
|
+
<h3>📝 Output</h3>
|
|
289
|
+
<div id="output">Pronto per eseguire i test...</div>
|
|
290
|
+
</div>
|
|
291
|
+
|
|
292
|
+
<div class="card">
|
|
293
|
+
<h3>ℹ️ Informazioni</h3>
|
|
294
|
+
<p><strong>Progetto:</strong> ${this.projectRoot}</p>
|
|
295
|
+
<p><strong>Directory Test:</strong> ${this.testsDir}</p>
|
|
296
|
+
<p><strong>Server:</strong> http://localhost:${this.port}</p>
|
|
297
|
+
</div>
|
|
298
|
+
|
|
299
|
+
<script>
|
|
300
|
+
function log(message) {
|
|
301
|
+
document.getElementById('output').textContent = message;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async function runTests() {
|
|
305
|
+
log('🚀 Esecuzione test in corso...\\n\\nAttendi, questo potrebbe richiedere alcuni minuti...');
|
|
306
|
+
|
|
307
|
+
try {
|
|
308
|
+
const response = await fetch('/api/run', {
|
|
309
|
+
method: 'POST',
|
|
310
|
+
headers: { 'Content-Type': 'application/json' },
|
|
311
|
+
body: JSON.stringify({ reporter: 'html', headed: false })
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
const result = await response.json();
|
|
315
|
+
|
|
316
|
+
if (result.success) {
|
|
317
|
+
log('✅ Test completati con successo!\\n\\n' + result.output);
|
|
318
|
+
setTimeout(() => {
|
|
319
|
+
window.location.href = '/';
|
|
320
|
+
}, 2000);
|
|
321
|
+
} else {
|
|
322
|
+
log('❌ Errore durante l\\'esecuzione dei test:\\n\\n' + (result.error || result.output));
|
|
323
|
+
}
|
|
324
|
+
} catch (error) {
|
|
325
|
+
log('❌ Errore di rete: ' + error.message);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function viewReport() {
|
|
330
|
+
window.location.href = '/';
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
async function getTestList() {
|
|
334
|
+
log('📋 Caricamento lista test...');
|
|
335
|
+
|
|
336
|
+
try {
|
|
337
|
+
const response = await fetch('/api/tests');
|
|
338
|
+
const result = await response.json();
|
|
339
|
+
|
|
340
|
+
if (result.success) {
|
|
341
|
+
log('✅ Trovati ' + result.count + ' file di test:\\n\\n' +
|
|
342
|
+
result.files.map(f => ' • ' + f).join('\\n'));
|
|
343
|
+
} else {
|
|
344
|
+
log('❌ Errore: ' + result.error);
|
|
345
|
+
}
|
|
346
|
+
} catch (error) {
|
|
347
|
+
log('❌ Errore di rete: ' + error.message);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
</script>
|
|
351
|
+
</body>
|
|
352
|
+
</html>
|
|
353
|
+
`);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
async start() {
|
|
357
|
+
return new Promise((resolve, reject) => {
|
|
358
|
+
this.server = this.app.listen(this.port, () => {
|
|
359
|
+
console.log(`
|
|
360
|
+
╔════════════════════════════════════════════════════════════╗
|
|
361
|
+
║ ║
|
|
362
|
+
║ 🎭 Playwright Report Server ATTIVO ║
|
|
363
|
+
║ ║
|
|
364
|
+
║ 📊 Report disponibile su: ║
|
|
365
|
+
║ → http://localhost:${this.port} ║
|
|
366
|
+
║ ║
|
|
367
|
+
║ 📋 Dashboard: ║
|
|
368
|
+
║ → http://localhost:${this.port}/dashboard ║
|
|
369
|
+
║ ║
|
|
370
|
+
║ 📁 Progetto: ${this.projectRoot.slice(-40).padEnd(40)}║
|
|
371
|
+
║ 📂 Test Dir: ${this.testsDir.padEnd(40)} ║
|
|
372
|
+
║ ║
|
|
373
|
+
║ 💡 Il server rimarrà attivo in background ║
|
|
374
|
+
║ ║
|
|
375
|
+
╚════════════════════════════════════════════════════════════╝
|
|
376
|
+
`);
|
|
377
|
+
resolve();
|
|
378
|
+
}).on('error', (error) => {
|
|
379
|
+
if (error.code === 'EADDRINUSE') {
|
|
380
|
+
console.log(`
|
|
381
|
+
⚠️ La porta ${this.port} è già in uso.
|
|
382
|
+
|
|
383
|
+
Il server dei report è probabilmente già attivo.
|
|
384
|
+
Accedi a: http://localhost:${this.port}
|
|
385
|
+
|
|
386
|
+
Per usare una porta diversa:
|
|
387
|
+
npx playwright-daemon --port <numero>
|
|
388
|
+
`);
|
|
389
|
+
resolve(); // Non è un errore fatale
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
reject(error);
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
stop() {
|
|
398
|
+
if (this.server) {
|
|
399
|
+
this.server.close();
|
|
400
|
+
console.log('\n👋 Report server fermato\n');
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
exports.ReportDaemon = ReportDaemon;
|
|
405
|
+
// Export per uso programmatico
|
|
406
|
+
function createDaemon(options = {}) {
|
|
407
|
+
return new ReportDaemon(options);
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=report-daemon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-daemon.js","sourceRoot":"","sources":["../src/report-daemon.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsYA,oCAEC;AAtYD,sDAA8B;AAC9B,+CAAqD;AACrD,2CAA6B;AAC7B,gDAAkC;AAClC,gDAAwB;AAcxB,MAAa,YAAY;IACf,GAAG,CAAsB;IACzB,MAAM,CAAuB;IAC7B,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,QAAQ,CAAS;IACjB,MAAM,GAAQ,IAAI,CAAC;IAE3B,YAAY,UAA+B,EAAE;QAC3C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,4BAA4B;QAC9D,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC;QAE5C,IAAI,CAAC,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,kCAAoB,CAAC;YACrC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,WAAW,EAAE,CAAC;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IAC5D,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-and-show.d.ts","sourceRoot":"","sources":["../src/run-and-show.ts"],"names":[],"mappings":";AAKA;;;;;GAKG;AAEH,iBAAe,UAAU,
|
|
1
|
+
{"version":3,"file":"run-and-show.d.ts","sourceRoot":"","sources":["../src/run-and-show.ts"],"names":[],"mappings":";AAKA;;;;;GAKG;AAEH,iBAAe,UAAU,kBA6HxB;AAUD,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/run-and-show.js
CHANGED
|
@@ -131,17 +131,20 @@ Questo comando:
|
|
|
131
131
|
console.log('\n✅ Test completati con successo!\n');
|
|
132
132
|
// Step 3: Mostra il report
|
|
133
133
|
console.log('📊 Avvio report UI...\n');
|
|
134
|
-
const { url } = await runner.showReport();
|
|
134
|
+
const { url, process: reportProcess } = await runner.showReport();
|
|
135
135
|
console.log('━'.repeat(50));
|
|
136
136
|
console.log(`\n✨ Report disponibile su: ${url}`);
|
|
137
137
|
console.log('\n💡 Il report si aprirà automaticamente nel browser');
|
|
138
138
|
console.log(' Premi Ctrl+C per chiudere il report e uscire\n');
|
|
139
139
|
console.log('━'.repeat(50));
|
|
140
|
-
// Mantieni il processo attivo
|
|
141
|
-
|
|
140
|
+
// Mantieni il processo attivo e gestisci cleanup
|
|
141
|
+
const cleanup = () => {
|
|
142
142
|
console.log('\n\n👋 Chiusura report...');
|
|
143
|
+
runner.stopReportServer();
|
|
143
144
|
process.exit(0);
|
|
144
|
-
}
|
|
145
|
+
};
|
|
146
|
+
process.on('SIGINT', cleanup);
|
|
147
|
+
process.on('SIGTERM', cleanup);
|
|
145
148
|
}
|
|
146
149
|
catch (error) {
|
|
147
150
|
console.error('\n❌ Errore:', error.message);
|
package/dist/run-and-show.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-and-show.js","sourceRoot":"","sources":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C,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC;QAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAEjC,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"}
|
package/dist/test-runner.d.ts
CHANGED
|
@@ -13,7 +13,16 @@ export interface TestResult {
|
|
|
13
13
|
export declare class PlaywrightTestRunner {
|
|
14
14
|
private projectRoot;
|
|
15
15
|
private testsDir;
|
|
16
|
+
private reportProcess;
|
|
16
17
|
constructor(options?: TestRunnerOptions);
|
|
18
|
+
/**
|
|
19
|
+
* Verifica se una porta è già in uso
|
|
20
|
+
*/
|
|
21
|
+
private isPortInUse;
|
|
22
|
+
/**
|
|
23
|
+
* Chiude il processo del report server
|
|
24
|
+
*/
|
|
25
|
+
stopReportServer(): void;
|
|
17
26
|
getTestFiles(): Promise<string[]>;
|
|
18
27
|
runTests(options?: TestRunnerOptions): Promise<TestResult>;
|
|
19
28
|
showReport(): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-runner.d.ts","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-runner.d.ts","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7C,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAAa;gBAEtB,OAAO,GAAE,iBAAsB;IAK3C;;OAEG;YACW,WAAW;IAqBzB;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAQlB,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAuBjC,QAAQ,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC;IAsC9D,UAAU,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC;CAyD3D"}
|
package/dist/test-runner.js
CHANGED
|
@@ -38,14 +38,47 @@ const child_process_1 = require("child_process");
|
|
|
38
38
|
const util_1 = require("util");
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
40
|
const fs = __importStar(require("fs/promises"));
|
|
41
|
+
const net = __importStar(require("net"));
|
|
41
42
|
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
42
43
|
class PlaywrightTestRunner {
|
|
43
44
|
projectRoot;
|
|
44
45
|
testsDir;
|
|
46
|
+
reportProcess = null;
|
|
45
47
|
constructor(options = {}) {
|
|
46
48
|
this.projectRoot = options.projectRoot || process.cwd();
|
|
47
49
|
this.testsDir = options.testsDir || 'tests';
|
|
48
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Verifica se una porta è già in uso
|
|
53
|
+
*/
|
|
54
|
+
async isPortInUse(port) {
|
|
55
|
+
return new Promise((resolve) => {
|
|
56
|
+
const server = net.createServer();
|
|
57
|
+
server.once('error', (err) => {
|
|
58
|
+
if (err.code === 'EADDRINUSE') {
|
|
59
|
+
resolve(true);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
resolve(false);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
server.once('listening', () => {
|
|
66
|
+
server.close();
|
|
67
|
+
resolve(false);
|
|
68
|
+
});
|
|
69
|
+
server.listen(port);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Chiude il processo del report server
|
|
74
|
+
*/
|
|
75
|
+
stopReportServer() {
|
|
76
|
+
if (this.reportProcess) {
|
|
77
|
+
this.reportProcess.kill();
|
|
78
|
+
this.reportProcess = null;
|
|
79
|
+
console.log('✅ Report server chiuso');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
49
82
|
async getTestFiles() {
|
|
50
83
|
const testsPath = path.join(this.projectRoot, this.testsDir);
|
|
51
84
|
try {
|
|
@@ -102,23 +135,47 @@ class PlaywrightTestRunner {
|
|
|
102
135
|
}
|
|
103
136
|
async showReport() {
|
|
104
137
|
const reportPath = path.join(this.projectRoot, 'playwright-report');
|
|
138
|
+
const reportPort = 9323; // Porta default di Playwright
|
|
105
139
|
try {
|
|
106
140
|
await fs.access(reportPath);
|
|
107
141
|
}
|
|
108
142
|
catch {
|
|
109
143
|
throw new Error('Report non trovato. Esegui prima i test con reporter html.');
|
|
110
144
|
}
|
|
145
|
+
// Verifica se la porta è già in uso
|
|
146
|
+
const portInUse = await this.isPortInUse(reportPort);
|
|
147
|
+
if (portInUse) {
|
|
148
|
+
console.log(`\n💡 Il report server è già attivo sulla porta ${reportPort}`);
|
|
149
|
+
console.log(` Riutilizzo server esistente: http://localhost:${reportPort}\n`);
|
|
150
|
+
return {
|
|
151
|
+
url: `http://localhost:${reportPort}`,
|
|
152
|
+
process: null, // Nessun nuovo processo creato
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
// Se la porta è libera, avvia un nuovo server
|
|
111
156
|
return new Promise((resolve, reject) => {
|
|
112
157
|
// Usa il playwright dalla libreria
|
|
113
158
|
const playwrightBin = path.join(__dirname, '../node_modules/.bin/playwright');
|
|
114
159
|
const showProcess = (0, child_process_1.exec)(`${playwrightBin} show-report`, { cwd: this.projectRoot });
|
|
160
|
+
// Salva il riferimento al processo
|
|
161
|
+
this.reportProcess = showProcess;
|
|
162
|
+
// Setup graceful shutdown
|
|
163
|
+
const cleanup = () => {
|
|
164
|
+
this.stopReportServer();
|
|
165
|
+
};
|
|
166
|
+
process.on('SIGINT', cleanup);
|
|
167
|
+
process.on('SIGTERM', cleanup);
|
|
168
|
+
process.on('exit', cleanup);
|
|
169
|
+
showProcess.on('error', (error) => {
|
|
170
|
+
console.error('\n❌ Errore durante l\'avvio del report server:', error.message);
|
|
171
|
+
reject(error);
|
|
172
|
+
});
|
|
115
173
|
setTimeout(() => {
|
|
116
174
|
resolve({
|
|
117
|
-
url:
|
|
175
|
+
url: `http://localhost:${reportPort}`,
|
|
118
176
|
process: showProcess,
|
|
119
177
|
});
|
|
120
178
|
}, 2000);
|
|
121
|
-
showProcess.on('error', reject);
|
|
122
179
|
});
|
|
123
180
|
}
|
|
124
181
|
}
|
package/dist/test-runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-runner.js","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAqC;AACrC,+BAAiC;AACjC,2CAA6B;AAC7B,gDAAkC;
|
|
1
|
+
{"version":3,"file":"test-runner.js","sourceRoot":"","sources":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B,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChC,OAAO,CAAC,KAAK,CAAC,gDAAgD,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;gBAC/E,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;YAEH,UAAU,CAAC,GAAG,EAAE;gBACd,OAAO,CAAC;oBACN,GAAG,EAAE,oBAAoB,UAAU,EAAE;oBACrC,OAAO,EAAE,WAAW;iBACrB,CAAC,CAAC;YACL,CAAC,EAAE,IAAI,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAnKD,oDAmKC"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playwright-test-runner/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Libreria agnostica per eseguire test Playwright con server Express e UI report",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"bin": {
|
|
8
8
|
"playwright-runner": "dist/cli.js",
|
|
9
9
|
"playwright-test": "dist/run-and-show.js",
|
|
10
|
-
"playwright-ui": "dist/web-cli.js"
|
|
10
|
+
"playwright-ui": "dist/web-cli.js",
|
|
11
|
+
"playwright-daemon": "dist/daemon-cli.js"
|
|
11
12
|
},
|
|
12
13
|
"scripts": {
|
|
13
14
|
"build": "tsc",
|
|
14
15
|
"dev": "tsc --watch",
|
|
15
16
|
"start": "node dist/index.js",
|
|
16
|
-
"prepare": "npm run build"
|
|
17
|
+
"prepare": "npm run build",
|
|
18
|
+
"postinstall": "node scripts/postinstall.js"
|
|
17
19
|
},
|
|
18
20
|
"keywords": [
|
|
19
21
|
"playwright",
|