@apica-io/asm-playwright-runner 1.0.0-dev.3 → 1.0.0-dev.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/dist/runner.js CHANGED
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
35
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
27
  };
@@ -54,227 +45,221 @@ class PlaywrightRunner {
54
45
  this.options = null;
55
46
  this.logger = (0, log4js_1.getLogger)(PlaywrightRunner.name);
56
47
  }
57
- init(collectionPath, options) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- var _a;
60
- this.logger.info("Initializing PlaywrightRunner...");
61
- // Normalize resultDir
62
- if (!options.resultDir || options.resultDir.trim() === "") {
63
- options.resultDir = runnerConfig_1.ResultDir.BASE_DIR;
64
- this.logger.debug("No resultDir specified. Defaulting to 'results'.");
65
- }
66
- this.options = options;
67
- // Detect script type
68
- this.options.scriptType = yield this.detectScriptType(collectionPath);
69
- this.options.isValidScript = this.options.scriptType !== undefined;
70
- if (!this.options.isValidScript) {
71
- this.logger.warn("Script is not valid.");
72
- process.exit(9);
73
- }
74
- // Skip browser setup for Playwright Test files
75
- if (this.options.scriptType === runnerConfig_1.ScriptType.PLAYWRIGHT_TEST) {
76
- this.logger.info("Playwright Test detected. Skipping manual browser setup.");
77
- return;
48
+ async init(collectionPath, options) {
49
+ this.logger.info("Initializing PlaywrightRunner...");
50
+ // Normalize resultDir
51
+ if (!options.resultDir || options.resultDir.trim() === "") {
52
+ options.resultDir = runnerConfig_1.ResultDir.BASE_DIR;
53
+ this.logger.debug("No resultDir specified. Defaulting to 'results'.");
54
+ }
55
+ this.options = options;
56
+ // Detect script type
57
+ this.options.scriptType = await this.detectScriptType(collectionPath);
58
+ this.options.isValidScript = this.options.scriptType !== undefined;
59
+ if (!this.options.isValidScript) {
60
+ this.logger.warn("Script is not valid.");
61
+ process.exit(9);
62
+ }
63
+ // Skip browser setup for Playwright Test files
64
+ if (this.options.scriptType === runnerConfig_1.ScriptType.PLAYWRIGHT_TEST) {
65
+ this.logger.info("Playwright Test detected. Skipping manual browser setup.");
66
+ return;
67
+ }
68
+ // Browser setup
69
+ const browserType = options.browser || runnerConfig_1.BrowserType.CHROMIUM;
70
+ const headless = options.headless;
71
+ this.logger.debug(`Browser type: ${browserType}, headless: ${headless}`);
72
+ this.browser = await (browserType === runnerConfig_1.BrowserType.FIREFOX ? playwright_1.firefox :
73
+ browserType === runnerConfig_1.BrowserType.WEBKIT ? playwright_1.webkit :
74
+ playwright_1.chromium).launch({
75
+ headless,
76
+ ...(options.chromiumPath && { executablePath: options.chromiumPath })
77
+ });
78
+ this.logger.info("Browser launched successfully.");
79
+ let headers = {};
80
+ if (options.extraHTTPHeaders) {
81
+ try {
82
+ headers = JSON.parse(options.extraHTTPHeaders);
78
83
  }
79
- // Browser setup
80
- const browserType = options.browser || runnerConfig_1.BrowserType.CHROMIUM;
81
- const headless = options.headless;
82
- this.logger.debug(`Browser type: ${browserType}, headless: ${headless}`);
83
- this.browser = yield (browserType === runnerConfig_1.BrowserType.FIREFOX ? playwright_1.firefox :
84
- browserType === runnerConfig_1.BrowserType.WEBKIT ? playwright_1.webkit :
85
- playwright_1.chromium).launch(Object.assign({ headless }, (options.chromiumPath && { executablePath: options.chromiumPath })));
86
- this.logger.info("Browser launched successfully.");
87
- let headers = {};
88
- if (options.extraHTTPHeaders) {
89
- try {
90
- headers = JSON.parse(options.extraHTTPHeaders);
91
- }
92
- catch (err) {
93
- this.logger.warn("Invalid JSON for extraHTTPHeaders, ignoring:", options.extraHTTPHeaders);
94
- headers = {}; // fallback to empty headers
95
- }
84
+ catch (err) {
85
+ this.logger.warn("Invalid JSON for extraHTTPHeaders, ignoring:", options.extraHTTPHeaders);
86
+ headers = {}; // fallback to empty headers
96
87
  }
97
- this.context = yield this.browser.newContext(Object.assign(Object.assign({ ignoreHTTPSErrors: true }, (options.sslClientCert && {
88
+ }
89
+ this.context = await this.browser.newContext({
90
+ ignoreHTTPSErrors: true,
91
+ ...(options.sslClientCert && {
98
92
  clientCert: {
99
93
  cert: options.sslClientCert,
100
94
  key: options.sslClientKey,
101
95
  passphrase: options.sslClientPassphrase
102
96
  }
103
- })), { extraHTTPHeaders: headers }));
104
- this.logger.info("Browser context created.");
105
- yield this.context.tracing.start({ snapshots: true, screenshots: true, sources: true });
106
- this.logger.info("Tracing started (snapshots, screenshots, sources enabled).");
107
- this.page = yield this.context.newPage();
108
- // @ts-ignore
109
- if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.scriptType) != runnerConfig_1.ScriptType.PLAYWRIGHT_TEST && this.options.timeout != null) {
110
- this.page.setDefaultTimeout(Number(this.options.timeout));
111
- }
112
- this.logger.info("New page created.");
97
+ }),
98
+ extraHTTPHeaders: headers,
113
99
  });
100
+ this.logger.info("Browser context created.");
101
+ await this.context.tracing.start({ snapshots: true, screenshots: true, sources: true });
102
+ this.logger.info("Tracing started (snapshots, screenshots, sources enabled).");
103
+ this.page = await this.context.newPage();
104
+ // @ts-ignore
105
+ if (this.options?.scriptType != runnerConfig_1.ScriptType.PLAYWRIGHT_TEST && this.options.timeout != null) {
106
+ this.page.setDefaultTimeout(Number(this.options.timeout));
107
+ }
108
+ this.logger.info("New page created.");
114
109
  }
115
- run(collectionPath, options) {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- var _a;
118
- this.logger.info(`Running collection: ${collectionPath}`);
119
- // Default trace path(s)
120
- let tracePaths = [
121
- options.resultDir
122
- ? path_1.default.join(options.resultDir, "trace.zip")
123
- : "trace.zip"
124
- ];
125
- switch ((_a = this.options) === null || _a === void 0 ? void 0 : _a.scriptType) {
126
- case runnerConfig_1.ScriptType.JSON: {
127
- const flow = (0, helper_1.loadFlow)(collectionPath);
128
- this.logger.info(`Loaded flow: ${flow.name} with ${flow.steps.length} steps`);
129
- for (const [index, step] of flow.steps.entries()) {
130
- const handler = actions_1.actionRegistry[step.action];
131
- this.logger.debug(`Executing step ${index}: action=${step.action}`);
132
- try {
133
- if (!handler)
134
- this.logger.error(`Unknown action: ${step.action}`);
135
- if (!this.page) {
136
- this.logger.error("Page not initialized. Did you call init()?");
137
- process.exit(9);
138
- }
139
- yield handler(this.page, step);
140
- }
141
- catch (err) {
142
- this.logger.error(`Step ${index} failed: ${err.message}`, err);
143
- }
144
- }
145
- break;
146
- }
147
- case runnerConfig_1.ScriptType.PLAYWRIGHT: {
148
- this.logger.info("Detected plain Playwright script with default export.");
149
- const mod = yield Promise.resolve(`${path_1.default.resolve(collectionPath)}`).then(s => __importStar(require(s)));
150
- const fn = mod.default;
151
- if (typeof fn !== "function") {
152
- throw new Error("Script does not export a default function");
153
- }
110
+ async run(collectionPath, options) {
111
+ this.logger.info(`Running collection: ${collectionPath}`);
112
+ // Default trace path(s)
113
+ let tracePaths = [
114
+ options.resultDir
115
+ ? path_1.default.join(options.resultDir, "trace.zip")
116
+ : "trace.zip"
117
+ ];
118
+ switch (this.options?.scriptType) {
119
+ case runnerConfig_1.ScriptType.JSON: {
120
+ const flow = (0, helper_1.loadFlow)(collectionPath);
121
+ this.logger.info(`Loaded flow: ${flow.name} with ${flow.steps.length} steps`);
122
+ for (const [index, step] of flow.steps.entries()) {
123
+ const handler = actions_1.actionRegistry[step.action];
124
+ this.logger.debug(`Executing step ${index}: action=${step.action}`);
154
125
  try {
155
- yield fn(this.page);
156
- this.logger.info("Script execution finished.");
126
+ if (!handler)
127
+ this.logger.error(`Unknown action: ${step.action}`);
128
+ if (!this.page) {
129
+ this.logger.error("Page not initialized. Did you call init()?");
130
+ process.exit(9);
131
+ }
132
+ await handler(this.page, step);
157
133
  }
158
134
  catch (err) {
159
- this.logger.error(`Script execution failed: ${err.message}`);
135
+ this.logger.error(`Step ${index} failed: ${err.message}`, err);
160
136
  }
161
- break;
162
- }
163
- case runnerConfig_1.ScriptType.PLAYWRIGHT_TEST: {
164
- this.logger.info("Detected Playwright Test file. Running via CLI...");
165
- const args = [
166
- "playwright",
167
- "test",
168
- collectionPath,
169
- "--browser", options.browser || runnerConfig_1.BrowserType.CHROMIUM,
170
- "--output", options.resultDir || "results",
171
- "--trace", "on"
172
- ];
173
- if (options.timeout != null)
174
- args.push("--timeout", options.timeout);
175
- if (!options.headless)
176
- args.push("--headed");
177
- // if (options.verbose) args.push("--verbose");
178
- this.logger.debug(`Spawning Playwright CLI: npx ${args.join(" ")}`);
179
- yield new Promise((resolve) => {
180
- const proc = (0, node_child_process_1.spawn)("npx", args, { stdio: "inherit", shell: true });
181
- proc.on("close", (code) => {
182
- if (code === 0) {
183
- this.logger.info("Playwright Test finished successfully.");
184
- }
185
- else {
186
- this.logger.error(`Playwright Test exited with code ${code}`);
187
- }
188
- tracePaths = (0, helper_1.collectTraceFiles)(options.resultDir || "results");
189
- resolve();
190
- });
191
- });
192
- break;
193
137
  }
194
- default:
195
- this.logger.error("Unsupported or invalid script type.");
196
- process.exit(9);
138
+ break;
197
139
  }
198
- this.logger.info("Stopping tracing...");
199
- yield this.traceProcess(tracePaths);
200
- });
201
- }
202
- traceProcess(tracePaths) {
203
- return __awaiter(this, void 0, void 0, function* () {
204
- var _a, _b, _c, _d, _e, _f, _g;
205
- if (!(tracePaths === null || tracePaths === void 0 ? void 0 : tracePaths.length)) {
206
- this.logger.warn("No trace paths provided.");
207
- return;
208
- }
209
- // Only stop tracing if this.context is active and we’re handling a live run
210
- if (this.context && ((_a = this.options) === null || _a === void 0 ? void 0 : _a.scriptType) != runnerConfig_1.ScriptType.PLAYWRIGHT_TEST) {
211
- yield this.context.tracing.stop({
212
- path: tracePaths[0]
213
- });
214
- this.logger.info(`Trace saved to ${tracePaths}`);
215
- }
216
- const models = {};
217
- for (const tracePath of tracePaths) {
140
+ case runnerConfig_1.ScriptType.PLAYWRIGHT: {
141
+ this.logger.info("Detected plain Playwright script with default export.");
142
+ const mod = await Promise.resolve(`${path_1.default.resolve(collectionPath)}`).then(s => __importStar(require(s)));
143
+ const fn = mod.default;
144
+ if (typeof fn !== "function") {
145
+ throw new Error("Script does not export a default function");
146
+ }
218
147
  try {
219
- this.logger.info(`Parsing trace: ${tracePath}`);
220
- const traceModel = yield (0, parser_1.prepareTraceModel)(tracePath, (_b = this.options) === null || _b === void 0 ? void 0 : _b.logLevel);
221
- const runName = path_1.default.basename(path_1.default.dirname(tracePath));
222
- models[runName] = traceModel;
223
- const individualPath = path_1.default.join(path_1.default.dirname(tracePath), RESULT_FILE);
224
- fs_1.default.writeFileSync(individualPath, JSON.stringify({ "__self": traceModel }, null, 2), "utf-8");
225
- this.logger.debug(`Individual trace model written to ${individualPath}`);
148
+ await fn(this.page);
149
+ this.logger.info("Script execution finished.");
226
150
  }
227
151
  catch (err) {
228
- this.logger.error(`Failed to process trace ${tracePath}: ${err.message}`, err);
152
+ this.logger.error(`Script execution failed: ${err.message}`);
229
153
  }
154
+ break;
230
155
  }
231
- // Write combined model if more than one trace
232
- if (((_c = this.options) === null || _c === void 0 ? void 0 : _c.scriptType) == runnerConfig_1.ScriptType.PLAYWRIGHT_TEST) {
233
- const combinedPath = ((_d = this.options) === null || _d === void 0 ? void 0 : _d.resultDir)
234
- ? path_1.default.join(this.options.resultDir, RESULT_FILE)
235
- : RESULT_FILE;
236
- fs_1.default.writeFileSync(combinedPath, JSON.stringify(models, null, 2), "utf-8");
237
- this.logger.info(`Combined trace model written to ${combinedPath}`);
238
- }
239
- const resourceDir = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.resultDir) !== null && _f !== void 0 ? _f : runnerConfig_1.ResultDir.BASE_DIR;
240
- const finalZipPath = path_1.default.join(resourceDir, `artifacts.zip`);
241
- yield (0, parser_1.zipResources)(finalZipPath, path_1.default.join(resourceDir, runnerConfig_1.ResultDir.SCREENSHOT), path_1.default.join(resourceDir, runnerConfig_1.ResultDir.SOURCE));
242
- if ((_g = this.options) === null || _g === void 0 ? void 0 : _g.returnResult) {
243
- console.log(JSON.stringify(models));
156
+ case runnerConfig_1.ScriptType.PLAYWRIGHT_TEST: {
157
+ this.logger.info("Detected Playwright Test file. Running via CLI...");
158
+ const args = [
159
+ "playwright",
160
+ "test",
161
+ collectionPath,
162
+ "--browser", options.browser || runnerConfig_1.BrowserType.CHROMIUM,
163
+ "--output", options.resultDir || "results",
164
+ "--trace", "on"
165
+ ];
166
+ if (options.timeout != null)
167
+ args.push("--timeout", options.timeout);
168
+ if (!options.headless)
169
+ args.push("--headed");
170
+ // if (options.verbose) args.push("--verbose");
171
+ this.logger.debug(`Spawning Playwright CLI: npx ${args.join(" ")}`);
172
+ await new Promise((resolve) => {
173
+ const proc = (0, node_child_process_1.spawn)("npx", args, { stdio: "inherit", shell: true });
174
+ proc.on("close", (code) => {
175
+ if (code === 0) {
176
+ this.logger.info("Playwright Test finished successfully.");
177
+ }
178
+ else {
179
+ this.logger.error(`Playwright Test exited with code ${code}`);
180
+ }
181
+ tracePaths = (0, helper_1.collectTraceFiles)(options.resultDir || "results");
182
+ resolve();
183
+ });
184
+ });
185
+ break;
244
186
  }
245
- });
187
+ default:
188
+ this.logger.error("Unsupported or invalid script type.");
189
+ process.exit(9);
190
+ }
191
+ this.logger.info("Stopping tracing...");
192
+ await this.traceProcess(tracePaths);
246
193
  }
247
- detectScriptType(collectionPath) {
248
- return __awaiter(this, void 0, void 0, function* () {
194
+ async traceProcess(tracePaths) {
195
+ if (!tracePaths?.length) {
196
+ this.logger.warn("No trace paths provided.");
197
+ return;
198
+ }
199
+ // Only stop tracing if this.context is active and we’re handling a live run
200
+ if (this.context && this.options?.scriptType != runnerConfig_1.ScriptType.PLAYWRIGHT_TEST) {
201
+ await this.context.tracing.stop({
202
+ path: tracePaths[0]
203
+ });
204
+ this.logger.info(`Trace saved to ${tracePaths}`);
205
+ }
206
+ const models = {};
207
+ for (const tracePath of tracePaths) {
249
208
  try {
250
- const mod = yield Promise.resolve(`${path_1.default.resolve(collectionPath)}`).then(s => __importStar(require(s)));
251
- if (typeof mod.default === "function") {
252
- this.logger.debug("Detected plain Playwright script (default export).");
253
- return runnerConfig_1.ScriptType.PLAYWRIGHT;
254
- }
209
+ this.logger.info(`Parsing trace: ${tracePath}`);
210
+ const traceModel = await (0, parser_1.prepareTraceModel)(tracePath, this.options?.logLevel);
211
+ const runName = path_1.default.basename(path_1.default.dirname(tracePath));
212
+ models[runName] = traceModel;
213
+ const individualPath = path_1.default.join(path_1.default.dirname(tracePath), RESULT_FILE);
214
+ fs_1.default.writeFileSync(individualPath, JSON.stringify({ "__self": traceModel }, null, 2), "utf-8");
215
+ this.logger.debug(`Individual trace model written to ${individualPath}`);
255
216
  }
256
- catch (_a) {
257
- this.logger.debug("Dynamic import failed, falling back to file content check.");
217
+ catch (err) {
218
+ this.logger.error(`Failed to process trace ${tracePath}: ${err.message}`, err);
258
219
  }
259
- if (collectionPath.endsWith(".json")) {
260
- this.logger.debug("Detected JSON flow.");
261
- return runnerConfig_1.ScriptType.JSON;
262
- }
263
- const fileContent = fs_1.default.readFileSync(collectionPath, "utf-8");
264
- if (fileContent.includes("test(")) {
265
- this.logger.debug("Detected Playwright Test file.");
266
- return runnerConfig_1.ScriptType.PLAYWRIGHT_TEST;
220
+ }
221
+ // Write combined model if more than one trace
222
+ if (this.options?.scriptType == runnerConfig_1.ScriptType.PLAYWRIGHT_TEST) {
223
+ const combinedPath = this.options?.resultDir
224
+ ? path_1.default.join(this.options.resultDir, RESULT_FILE)
225
+ : RESULT_FILE;
226
+ fs_1.default.writeFileSync(combinedPath, JSON.stringify(models, null, 2), "utf-8");
227
+ this.logger.info(`Combined trace model written to ${combinedPath}`);
228
+ }
229
+ const resourceDir = this.options?.resultDir ?? runnerConfig_1.ResultDir.BASE_DIR;
230
+ const finalZipPath = path_1.default.join(resourceDir, `artifacts.zip`);
231
+ await (0, parser_1.zipResources)(finalZipPath, path_1.default.join(resourceDir, runnerConfig_1.ResultDir.SCREENSHOT), path_1.default.join(resourceDir, runnerConfig_1.ResultDir.SOURCE));
232
+ if (this.options?.returnResult) {
233
+ console.log(JSON.stringify(models));
234
+ }
235
+ }
236
+ async detectScriptType(collectionPath) {
237
+ try {
238
+ const mod = await Promise.resolve(`${path_1.default.resolve(collectionPath)}`).then(s => __importStar(require(s)));
239
+ this.logger.debug("mod", mod, collectionPath);
240
+ if (typeof mod.default === "function") {
241
+ this.logger.debug("Detected plain Playwright script (default export).");
242
+ return runnerConfig_1.ScriptType.PLAYWRIGHT;
267
243
  }
268
- return undefined;
269
- });
244
+ }
245
+ catch {
246
+ this.logger.debug("Dynamic import failed, falling back to file content check.");
247
+ }
248
+ if (collectionPath.endsWith(".json")) {
249
+ this.logger.debug("Detected JSON flow.");
250
+ return runnerConfig_1.ScriptType.JSON;
251
+ }
252
+ const fileContent = fs_1.default.readFileSync(collectionPath, "utf-8");
253
+ if (fileContent.includes("test(")) {
254
+ this.logger.debug("Detected Playwright Test file.");
255
+ return runnerConfig_1.ScriptType.PLAYWRIGHT_TEST;
256
+ }
257
+ return undefined;
270
258
  }
271
- close() {
272
- return __awaiter(this, void 0, void 0, function* () {
273
- var _a;
274
- this.logger.info("Closing browser...");
275
- yield ((_a = this.browser) === null || _a === void 0 ? void 0 : _a.close());
276
- this.logger.info("Browser closed.");
277
- });
259
+ async close() {
260
+ this.logger.info("Closing browser...");
261
+ await this.browser?.close();
262
+ this.logger.info("Browser closed.");
278
263
  }
279
264
  }
280
265
  exports.PlaywrightRunner = PlaywrightRunner;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apica-io/asm-playwright-runner",
3
- "version": "1.0.0-dev.3",
3
+ "version": "1.0.0-dev.5",
4
4
  "description": "CLI wrapper for Playwright collections or scripts with dynamic actions, config, and test result models.",
5
5
  "main": "dist/cli/index.js",
6
6
  "bin": {
@@ -10,13 +10,10 @@
10
10
  "build": "tsc",
11
11
  "start": "ts-node src/cli/ index.ts",
12
12
  "dev": "ts-node-dev --respawn src/cli/index.ts",
13
-
14
13
  "test:playwright-script": "ts-node src/cli samples/playwright-script.spec.ts --timeout 10000 --browser chromium --headless -v -r result1 -l debug",
15
14
  "test:playwright/test-script": "ts-node src/cli samples/playwright-test-script.spec.ts --browser chromium --headless -r result2 -l debug",
16
15
  "test:playwright-multi-script": "ts-node src/cli samples/playwright-multi-script.spec.ts --browser chromium --headless -v -r result3 -l debug",
17
-
18
16
  "test:betsson-script": "ts-node src/cli samples/betsson.spec.ts --browser chromium -r result-betsson --headless false -l debug --extraHTTPHeaders {\\\"x-obg-bypass-fabric\\\":\\\"1\\\",\\\"x-obg-experiments\\\":\\\"b1ccAR1gW0f8\\\"}",
19
-
20
17
  "test:playwright-json": "ts-node src/cli samples/example.json --browser chromium --headless -v -r results3",
21
18
  "test:google": "ts-node src/cli samples/google.json --browser chromium --headless -v -r playwright-multi-script",
22
19
  "test:google-firefox": "ts-node src/cli samples/google.json --browser firefox --headless -v -r playwright-multi-script"
@@ -37,12 +34,14 @@
37
34
  },
38
35
  "devDependencies": {
39
36
  "@playwright/test": "^1.60.0",
37
+ "@types/archiver": "^7.0.0",
40
38
  "@types/leaflet": "^1.9.15",
41
39
  "@types/node": "^25.6.2",
40
+ "@types/unzipper": "^0.10.11",
41
+ "archiver": "^5.3.2",
42
42
  "ts-node": "^10.9.2",
43
43
  "ts-node-dev": "^2.0.0",
44
44
  "typescript": "^5.4.0",
45
- "unzipper": "^0.12.3",
46
- "archiver": "^5.3.2"
45
+ "unzipper": "^0.12.3"
47
46
  }
48
47
  }
@@ -1,9 +1,9 @@
1
- import {expect, Page} from "playwright/test";
1
+ import {expect, Page} from "playwright/test";
2
2
 
3
- export default async function example(page: Page) {
4
- await page.goto("https://playwright.dev/");
5
- await expect(page).toHaveTitle(/Playwright/);
3
+ export default async function example(page: Page) {
4
+ await page.goto("https://playwright.dev/");
5
+ await expect(page).toHaveTitle(/Playwright/);
6
6
 
7
- await page.getByRole("link", { name: "Get started11" }).click();
8
- await expect(page.getByRole("heading", { name: "Installation" })).toBeVisible();
9
- }
7
+ await page.getByRole("link", { name: "Get started" }).click();
8
+ await expect(page.getByRole("heading", { name: "Installation" })).toBeVisible();
9
+ }
@@ -1,13 +1,11 @@
1
1
  import { test, expect } from '@playwright/test';
2
2
 
3
- /*
4
3
  test('has title', async ({ page }) => {
5
4
  await page.goto('https://playwright.dev/');
6
5
 
7
6
  // Expect a title "to contain" a substring.
8
7
  await expect(page).toHaveTitle(/Playwright/);
9
8
  });
10
- */
11
9
 
12
10
  test('get started link', async ({ page }) => {
13
11
  await page.goto('https://playwright.dev/');
package/src/lib/parser.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import unzipper from 'unzipper';
2
- import archiver from "archiver";
2
+ import archiver from 'archiver';
3
3
  import {Action, HookAction, StackFrame, TraceModel} from "../model/traceModel";
4
4
  import path from "path";
5
5
  import fs from "fs";
package/src/runner.ts CHANGED
@@ -242,6 +242,7 @@ export class PlaywrightRunner {
242
242
  private async detectScriptType(collectionPath: string): Promise<ScriptType | undefined> {
243
243
  try {
244
244
  const mod = await import(path.resolve(collectionPath));
245
+ this.logger.debug("mod", mod, collectionPath)
245
246
  if (typeof mod.default === "function") {
246
247
  this.logger.debug("Detected plain Playwright script (default export).");
247
248
  return ScriptType.PLAYWRIGHT;
package/tsconfig.json CHANGED
@@ -1,22 +1,14 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "es6",
4
- "module": "CommonJS",
5
- "outDir": "./dist",
6
- "rootDir": "src",
7
- "strict": true,
8
- "noImplicitAny": false,
9
- "esModuleInterop": true,
10
- "allowSyntheticDefaultImports": true,
11
- "allowJs": false,
12
- "jsx": "react-jsx",
13
- "isolatedModules": true,
14
- // "noEmit": true,
15
- "noImplicitOverride": true,
16
- "useUnknownInCatchVariables": false,
17
- "useDefineForClassFields": false,
18
- "skipLibCheck": true,
19
- "forceConsistentCasingInFileNames": true
3
+ "target": "ES2020", // modern async/await + optional chaining
4
+ "module": "CommonJS", // Node.js default
5
+ "moduleResolution": "node", // resolves imports correctly
6
+ "esModuleInterop": true, // allows default imports from CommonJS libs (like log4js)
7
+ "resolveJsonModule": true, // lets you import JSON files
8
+ "outDir": "./dist", // compiled output folder
9
+ "rootDir": "./src", // source folder
10
+ "strict": true, // enables strict type checking
11
+ "skipLibCheck": true // avoids type issues in node_modules
20
12
  },
21
13
  "include": ["src"],
22
14
  "exclude": ["node_modules", "dist", "results"]