playwright-cucumber-ts-steps 0.1.0 → 0.1.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.
Files changed (35) hide show
  1. package/dist/actions/clickSteps.js +35 -33
  2. package/dist/actions/cookieSteps.js +7 -5
  3. package/dist/actions/debugSteps.js +5 -3
  4. package/dist/actions/elementFindSteps.js +50 -48
  5. package/dist/actions/inputSteps.js +40 -35
  6. package/dist/actions/interceptionSteps.js +9 -7
  7. package/dist/actions/miscSteps.js +41 -36
  8. package/dist/actions/mouseSteps.js +10 -8
  9. package/dist/actions/scrollSteps.js +7 -5
  10. package/dist/actions/storageSteps.js +10 -8
  11. package/dist/assertions/buttonAndTextVisibilitySteps.js +25 -23
  12. package/dist/assertions/cookieSteps.js +7 -5
  13. package/dist/assertions/elementSteps.js +24 -22
  14. package/dist/assertions/formInputSteps.js +28 -26
  15. package/dist/assertions/interceptionRequestsSteps.js +27 -25
  16. package/dist/assertions/locationSteps.js +17 -15
  17. package/dist/assertions/roleTestIdSteps.js +12 -10
  18. package/dist/assertions/semanticSteps.js +9 -7
  19. package/dist/assertions/storageSteps.js +23 -18
  20. package/dist/assertions/visualSteps.js +41 -36
  21. package/dist/custom_setups/globalLogin.js +10 -5
  22. package/dist/custom_setups/loginHooks.js +30 -25
  23. package/dist/helpers/checkPeerDeps.d.ts +1 -0
  24. package/dist/helpers/checkPeerDeps.js +19 -0
  25. package/dist/helpers/compareSnapshots.js +15 -9
  26. package/dist/helpers/hooks.js +73 -35
  27. package/dist/helpers/utils/fakerUtils.js +32 -26
  28. package/dist/helpers/utils/index.js +19 -3
  29. package/dist/helpers/utils/optionsUtils.js +18 -8
  30. package/dist/helpers/utils/resolveUtils.js +19 -11
  31. package/dist/helpers/world.js +45 -8
  32. package/dist/iframes/frames.js +4 -2
  33. package/dist/index.js +43 -27
  34. package/dist/register.js +9 -1
  35. package/package.json +24 -8
@@ -1,6 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  // e2e/step_definitions/common/interceptionSteps.ts
2
- import { When } from "@cucumber/cucumber";
3
- When("I intercept URL {string} and stub body:", async function (url, body) {
4
+ const cucumber_1 = require("@cucumber/cucumber");
5
+ (0, cucumber_1.When)("I intercept URL {string} and stub body:", async function (url, body) {
4
6
  let parsedBody;
5
7
  try {
6
8
  parsedBody = JSON.parse(body);
@@ -19,14 +21,14 @@ When("I intercept URL {string} and stub body:", async function (url, body) {
19
21
  this.log(`Intercepted and stubbed URL "${url}" with body: ${JSON.stringify(parsedBody)}`);
20
22
  });
21
23
  //Making Direct API Requests (Optional, Advanced)
22
- When("I make request to {string}", async function (url) {
24
+ (0, cucumber_1.When)("I make request to {string}", async function (url) {
23
25
  const response = await this.page.request.get(url);
24
26
  const status = response.status();
25
27
  const body = await response.text();
26
28
  this.data.lastResponse = { status, body };
27
29
  this.log(`Made GET request to "${url}" — Status: ${status}`);
28
30
  });
29
- When("I make a POST request to {string} with JSON body:", async function (url, docString) {
31
+ (0, cucumber_1.When)("I make a POST request to {string} with JSON body:", async function (url, docString) {
30
32
  let payload;
31
33
  try {
32
34
  payload = JSON.parse(docString);
@@ -41,12 +43,12 @@ When("I make a POST request to {string} with JSON body:", async function (url, d
41
43
  this.data.lastResponse = { status, body };
42
44
  this.log(`Made POST request to "${url}" — Status: ${status}`);
43
45
  });
44
- When("I intercept URL {string}", async function (url) {
46
+ (0, cucumber_1.When)("I intercept URL {string}", async function (url) {
45
47
  await this.page.route(url, async (route) => {
46
48
  await route.continue();
47
49
  });
48
50
  });
49
- When("I intercept URL {string} and stub body {string}", async function (url, body) {
51
+ (0, cucumber_1.When)("I intercept URL {string} and stub body {string}", async function (url, body) {
50
52
  await this.page.route(url, (route) => {
51
53
  route.fulfill({
52
54
  status: 200,
@@ -55,7 +57,7 @@ When("I intercept URL {string} and stub body {string}", async function (url, bod
55
57
  });
56
58
  });
57
59
  });
58
- When("I make a request to {string}", async function (url) {
60
+ (0, cucumber_1.When)("I make a request to {string}", async function (url) {
59
61
  const response = await this.page.request.get(url);
60
62
  this.data.lastResponse = response;
61
63
  });
@@ -1,19 +1,24 @@
1
- import { When } from "@cucumber/cucumber";
2
- import dayjs from "dayjs";
3
- import { parseClickOptions, parseCheckOptions, parseFillOptions, parseHoverOptions, parseUncheckOptions, } from "../helpers/utils/optionsUtils";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cucumber_1 = require("@cucumber/cucumber");
7
+ const dayjs_1 = __importDefault(require("dayjs"));
8
+ const optionsUtils_1 = require("../helpers/utils/optionsUtils");
4
9
  //
5
10
  // Timers
6
11
  //
7
- When(/^I use fake timers$/, async function () {
12
+ (0, cucumber_1.When)(/^I use fake timers$/, async function () {
8
13
  const initialTime = Date.now();
9
14
  await this.page.clock.setFixedTime(initialTime);
10
15
  this.fakeTimersActive = true;
11
16
  });
12
- When(/^I use real timers$/, async function () {
17
+ (0, cucumber_1.When)(/^I use real timers$/, async function () {
13
18
  await this.page.clock.restore();
14
19
  this.fakeTimersActive = false;
15
20
  });
16
- When(/^I advance timers by (\d+) milliseconds$/, async function (ms) {
21
+ (0, cucumber_1.When)(/^I advance timers by (\d+) milliseconds$/, async function (ms) {
17
22
  if (this.fakeTimersActive) {
18
23
  await this.page.clock.tick(parseInt(ms));
19
24
  }
@@ -21,7 +26,7 @@ When(/^I advance timers by (\d+) milliseconds$/, async function (ms) {
21
26
  console.warn("Real timers active. Consider using setTimeout.");
22
27
  }
23
28
  });
24
- When(/^I advance timers by (\d+) seconds$/, async function (seconds) {
29
+ (0, cucumber_1.When)(/^I advance timers by (\d+) seconds$/, async function (seconds) {
25
30
  const ms = parseInt(seconds) * 1000;
26
31
  if (this.fakeTimersActive) {
27
32
  await this.page.clock.tick(ms);
@@ -30,16 +35,16 @@ When(/^I advance timers by (\d+) seconds$/, async function (seconds) {
30
35
  console.warn("Real timers active. Consider using setTimeout.");
31
36
  }
32
37
  });
33
- When(/^I wait (\d+) second[s]?$/, async function (seconds) {
38
+ (0, cucumber_1.When)(/^I wait (\d+) second[s]?$/, async function (seconds) {
34
39
  await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
35
40
  });
36
- When("I wait {int} milliseconds", async function (ms) {
41
+ (0, cucumber_1.When)("I wait {int} milliseconds", async function (ms) {
37
42
  await new Promise((res) => setTimeout(res, ms));
38
43
  });
39
44
  //
40
45
  // Events
41
46
  //
42
- When(/^I trigger "(.*)" event on "([^"]+)"$/, async function (eventType, selector) {
47
+ (0, cucumber_1.When)(/^I trigger "(.*)" event on "([^"]+)"$/, async function (eventType, selector) {
43
48
  await this.page
44
49
  .locator(selector)
45
50
  .evaluate((el, type) => {
@@ -50,17 +55,17 @@ When(/^I trigger "(.*)" event on "([^"]+)"$/, async function (eventType, selecto
50
55
  el.dispatchEvent(event);
51
56
  }, eventType);
52
57
  });
53
- When("I trigger event {string}", async function (eventName) {
58
+ (0, cucumber_1.When)("I trigger event {string}", async function (eventName) {
54
59
  if (!this.element)
55
60
  throw new Error("No element selected");
56
61
  await this.element.dispatchEvent(eventName);
57
62
  });
58
- When("I blur", async function () {
63
+ (0, cucumber_1.When)("I blur", async function () {
59
64
  if (!this.element)
60
65
  throw new Error("No element selected");
61
66
  await this.element.evaluate((el) => el.blur());
62
67
  });
63
- When("I focus", async function () {
68
+ (0, cucumber_1.When)("I focus", async function () {
64
69
  if (!this.element)
65
70
  throw new Error("No element selected");
66
71
  await this.element.focus();
@@ -68,22 +73,22 @@ When("I focus", async function () {
68
73
  //
69
74
  // Debugging / Logging
70
75
  //
71
- When(/^I log "(.*)"$/, async function (_, message) {
76
+ (0, cucumber_1.When)(/^I log "(.*)"$/, async function (_, message) {
72
77
  console.log(`[LOG]: ${message}`);
73
78
  });
74
- When(/^I debug$/, async function () {
79
+ (0, cucumber_1.When)(/^I debug$/, async function () {
75
80
  debugger;
76
81
  });
77
82
  //
78
83
  // Screenshot
79
84
  //
80
- When(/^I screenshot "(.*)"$/, async function (name) {
85
+ (0, cucumber_1.When)(/^I screenshot "(.*)"$/, async function (name) {
81
86
  await this.page.screenshot({
82
87
  path: `e2e/screenshots/${name}.png`,
83
88
  fullPage: true,
84
89
  });
85
90
  });
86
- When("I screenshot", async function () {
91
+ (0, cucumber_1.When)("I screenshot", async function () {
87
92
  const path = `screenshots/screenshot-${Date.now()}.png`;
88
93
  await this.page.screenshot({ path, fullPage: true });
89
94
  this.log?.(`Saved screenshot to ${path}`);
@@ -91,7 +96,7 @@ When("I screenshot", async function () {
91
96
  //
92
97
  // Page Navigation
93
98
  //
94
- When("I visit {string}", async function (urlOrAlias) {
99
+ (0, cucumber_1.When)("I visit {string}", async function (urlOrAlias) {
95
100
  let url = urlOrAlias;
96
101
  if (url.startsWith("@")) {
97
102
  const alias = url.substring(1);
@@ -108,16 +113,16 @@ When("I visit {string}", async function (urlOrAlias) {
108
113
  this.log?.(`Visiting: ${url}`);
109
114
  await this.page.goto(url);
110
115
  });
111
- When("I reload the page", async function () {
116
+ (0, cucumber_1.When)("I reload the page", async function () {
112
117
  await this.page.reload();
113
118
  });
114
- When("I go back", async function () {
119
+ (0, cucumber_1.When)("I go back", async function () {
115
120
  await this.page.goBack();
116
121
  });
117
- When("I go forward", async function () {
122
+ (0, cucumber_1.When)("I go forward", async function () {
118
123
  await this.page.goForward();
119
124
  });
120
- When("I pause", async function () {
125
+ (0, cucumber_1.When)("I pause", async function () {
121
126
  await this.page.pause();
122
127
  });
123
128
  //
@@ -139,13 +144,13 @@ const validUnits = [
139
144
  "year",
140
145
  "years",
141
146
  ];
142
- When('I store {string} {int} {word} {word} as "{word}"', async function (baseAlias, amount, unit, direction, newAlias) {
147
+ (0, cucumber_1.When)('I store {string} {int} {word} {word} as "{word}"', async function (baseAlias, amount, unit, direction, newAlias) {
143
148
  const baseDateRaw = this.data?.[baseAlias];
144
149
  if (!baseDateRaw)
145
150
  throw new Error(`Alias "${baseAlias}" not found`);
146
151
  if (!validUnits.includes(unit))
147
152
  throw new Error(`Invalid unit "${unit}"`);
148
- const baseDate = dayjs(baseDateRaw);
153
+ const baseDate = (0, dayjs_1.default)(baseDateRaw);
149
154
  if (!baseDate.isValid())
150
155
  throw new Error(`Invalid date for "${baseAlias}"`);
151
156
  const result = baseDate[direction === "before" ? "subtract" : "add"](amount, unit);
@@ -156,7 +161,7 @@ When('I store {string} {int} {word} {word} as "{word}"', async function (baseAli
156
161
  //
157
162
  // IFrame
158
163
  //
159
- When("I switch to iframe with selector {string}", async function (selector) {
164
+ (0, cucumber_1.When)("I switch to iframe with selector {string}", async function (selector) {
160
165
  const frameLocator = this.page.frameLocator(selector);
161
166
  await frameLocator
162
167
  .locator("body")
@@ -164,7 +169,7 @@ When("I switch to iframe with selector {string}", async function (selector) {
164
169
  this.frame = frameLocator;
165
170
  this.log?.(`🪟 Switched to iframe: ${selector}`);
166
171
  });
167
- When("I switch to iframe with title {string}", async function (title) {
172
+ (0, cucumber_1.When)("I switch to iframe with title {string}", async function (title) {
168
173
  const frames = this.page.frames();
169
174
  const match = frames.find((f) => f.title().then((t) => t.includes(title)));
170
175
  if (!match)
@@ -172,13 +177,13 @@ When("I switch to iframe with title {string}", async function (title) {
172
177
  this.frame = this.page.frameLocator(`iframe[title*="${title}"]`);
173
178
  this.log?.(`🪟 Switched to iframe titled: ${title}`);
174
179
  });
175
- When("I switch to iframe with selector {string} and wait for text {string}", async function (selector, expected) {
180
+ (0, cucumber_1.When)("I switch to iframe with selector {string} and wait for text {string}", async function (selector, expected) {
176
181
  const frameLocator = this.page.frameLocator(selector);
177
182
  await frameLocator.locator(`text=${expected}`).waitFor({ timeout: 10000 });
178
183
  this.frame = frameLocator;
179
184
  this.log?.(`🪟 Switched to iframe: ${selector}, waited for "${expected}"`);
180
185
  });
181
- When("I exit iframe", function () {
186
+ (0, cucumber_1.When)("I exit iframe", function () {
182
187
  this.exitIframe();
183
188
  });
184
189
  //
@@ -227,15 +232,15 @@ const actionDisplayNames = {
227
232
  fill: "Filled",
228
233
  };
229
234
  const locatorActions = {
230
- click: (el, table) => el.click(parseClickOptions(table)),
231
- hover: (el, table) => el.hover(parseHoverOptions(table)),
232
- check: (el, table) => el.check(parseCheckOptions(table)),
233
- uncheck: (el, table) => el.uncheck(parseUncheckOptions(table)),
235
+ click: (el, table) => el.click((0, optionsUtils_1.parseClickOptions)(table)),
236
+ hover: (el, table) => el.hover((0, optionsUtils_1.parseHoverOptions)(table)),
237
+ check: (el, table) => el.check((0, optionsUtils_1.parseCheckOptions)(table)),
238
+ uncheck: (el, table) => el.uncheck((0, optionsUtils_1.parseUncheckOptions)(table)),
234
239
  focus: (el) => el.focus(),
235
240
  blur: (el) => el.evaluate((e) => e.blur()),
236
- fill: (el, table) => el.fill("", parseFillOptions(table)), // Extend this to support value
241
+ fill: (el, table) => el.fill("", (0, optionsUtils_1.parseFillOptions)(table)), // Extend this to support value
237
242
  };
238
- When(/^I (\w+) the (first|last|random) (\d+)$/, async function (action, mode, count, table) {
243
+ (0, cucumber_1.When)(/^I (\w+) the (first|last|random) (\d+)$/, async function (action, mode, count, table) {
239
244
  const elements = await getElementsSubset(this, mode, count);
240
245
  const actionFn = locatorActions[action];
241
246
  if (!actionFn)
@@ -246,7 +251,7 @@ When(/^I (\w+) the (first|last|random) (\d+)$/, async function (action, mode, co
246
251
  this.log?.(`✅ ${actionDisplayNames[action] || action} element: "${label}"`);
247
252
  }
248
253
  });
249
- When(/^I (\w+) the (\d+)(?:st|nd|rd|th) element$/, async function (action, nth, table) {
254
+ (0, cucumber_1.When)(/^I (\w+) the (\d+)(?:st|nd|rd|th) element$/, async function (action, nth, table) {
250
255
  const elements = await getElementsSubset(this, "nth", nth);
251
256
  const actionFn = locatorActions[action];
252
257
  if (!actionFn)
@@ -257,7 +262,7 @@ When(/^I (\w+) the (\d+)(?:st|nd|rd|th) element$/, async function (action, nth,
257
262
  this.log?.(`✅ ${actionDisplayNames[action] || action} the ${toOrdinal(nth)} element: "${label}"`);
258
263
  }
259
264
  });
260
- When("I press key {string}", async function (key) {
265
+ (0, cucumber_1.When)("I press key {string}", async function (key) {
261
266
  if (!this.element)
262
267
  throw new Error("No element selected");
263
268
  await this.element.focus();
@@ -1,21 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  // e2e/step_definitions/common/mouseSteps.ts
2
- import { When } from "@cucumber/cucumber";
4
+ const cucumber_1 = require("@cucumber/cucumber");
3
5
  // 🧭 SCROLLING
4
6
  //
5
- When(/^I scroll "([^"]+)" into view$/, async function (selector) {
7
+ (0, cucumber_1.When)(/^I scroll "([^"]+)" into view$/, async function (selector) {
6
8
  await this.page.locator(selector).scrollIntoViewIfNeeded();
7
9
  });
8
- When(/^I scroll "([^"]+)" to position x:(\d+) y:(\d+)$/, async function (selector, x, y) {
10
+ (0, cucumber_1.When)(/^I scroll "([^"]+)" to position x:(\d+) y:(\d+)$/, async function (selector, x, y) {
9
11
  await this.page.locator(selector).evaluate((el, x, y) => {
10
12
  el.scrollTo(parseInt(x), parseInt(y));
11
13
  }, x, y);
12
14
  });
13
- When(/^I scroll to coordinates x:(\d+) y:(\d+)$/, async function (x, y) {
15
+ (0, cucumber_1.When)(/^I scroll to coordinates x:(\d+) y:(\d+)$/, async function (x, y) {
14
16
  await this.page.evaluate((x, y) => {
15
17
  window.scrollTo(parseInt(x), parseInt(y));
16
18
  }, x, y);
17
19
  });
18
- When(/^I scroll window to position top:(\d+) left:(\d+)$/, async function (top, left) {
20
+ (0, cucumber_1.When)(/^I scroll window to position top:(\d+) left:(\d+)$/, async function (top, left) {
19
21
  await this.page.evaluate((top, left) => {
20
22
  window.scrollTo({
21
23
  top: parseInt(top),
@@ -24,7 +26,7 @@ When(/^I scroll window to position top:(\d+) left:(\d+)$/, async function (top,
24
26
  });
25
27
  }, top, left);
26
28
  });
27
- When('I scroll to "{word}"', async function (direction) {
29
+ (0, cucumber_1.When)('I scroll to "{word}"', async function (direction) {
28
30
  const validDirections = ["top", "bottom", "left", "right"];
29
31
  if (!validDirections.includes(direction)) {
30
32
  throw new Error(`Invalid scroll direction "${direction}". Must be one of: ${validDirections.join(", ")}.`);
@@ -52,13 +54,13 @@ When('I scroll to "{word}"', async function (direction) {
52
54
  this.log?.(`🖱️ Scrolled to "${direction}"`);
53
55
  await this.page.waitForTimeout(500); // allow scroll to complete
54
56
  });
55
- When("I hover over the element {string}", async function (selector) {
57
+ (0, cucumber_1.When)("I hover over the element {string}", async function (selector) {
56
58
  const element = this.getScope().locator(selector);
57
59
  await element.hover();
58
60
  this.element = element;
59
61
  this.log?.(`🖱️ Hovered: ${selector}`);
60
62
  });
61
- When("I move mouse to coordinates {int}, {int}", async function (x, y) {
63
+ (0, cucumber_1.When)("I move mouse to coordinates {int}, {int}", async function (x, y) {
62
64
  await this.page.mouse.move(x, y);
63
65
  this.log?.(`🧭 Mouse moved to (${x}, ${y})`);
64
66
  });
@@ -1,21 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  // e2e/step_definitions/common/scrollSteps.ts
2
- import { When } from "@cucumber/cucumber";
3
- When("I scroll into view", async function () {
4
+ const cucumber_1 = require("@cucumber/cucumber");
5
+ (0, cucumber_1.When)("I scroll into view", async function () {
4
6
  const element = this.element;
5
7
  if (!element)
6
8
  throw new Error("No element selected");
7
9
  await element.scrollIntoViewIfNeeded();
8
10
  this.log("Scrolled selected element into view");
9
11
  });
10
- When("I scroll to position {int} {int}", async function (x, y) {
12
+ (0, cucumber_1.When)("I scroll to position {int} {int}", async function (x, y) {
11
13
  await this.page.evaluate(([x, y]) => window.scrollTo(x, y), [x, y]);
12
14
  this.log(`Scrolled window to position: ${x}, ${y}`);
13
15
  });
14
- When("I scroll window to position {int} {int}", async function (x, y) {
16
+ (0, cucumber_1.When)("I scroll window to position {int} {int}", async function (x, y) {
15
17
  await this.page.evaluate(([x, y]) => window.scrollTo(x, y), [x, y]);
16
18
  this.log(`Window scrolled to: ${x}, ${y}`);
17
19
  });
18
- When("I scroll window to x {int} and y {int}", async function (x, y) {
20
+ (0, cucumber_1.When)("I scroll window to x {int} and y {int}", async function (x, y) {
19
21
  await this.page.evaluate(([x, y]) => window.scrollTo(x, y), [x, y]);
20
22
  this.log(`Window scrolled to coordinates: (${x}, ${y})`);
21
23
  });
@@ -1,18 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  // e2e/step_definitions/common/actions/storageSteps.ts
2
- import { When } from "@cucumber/cucumber";
3
- When("I clear all local storage", async function () {
4
+ const cucumber_1 = require("@cucumber/cucumber");
5
+ (0, cucumber_1.When)("I clear all local storage", async function () {
4
6
  await this.page.evaluate(() => localStorage.clear());
5
7
  this.log("Cleared all local storage");
6
8
  });
7
- When("I clear local storage", async function () {
9
+ (0, cucumber_1.When)("I clear local storage", async function () {
8
10
  await this.page.evaluate(() => localStorage.clear());
9
11
  this.log("Cleared local storage (alias)");
10
12
  });
11
- When("I clear session storage", async function () {
13
+ (0, cucumber_1.When)("I clear session storage", async function () {
12
14
  await this.page.evaluate(() => sessionStorage.clear());
13
15
  this.log("Cleared session storage");
14
16
  });
15
- When("I clear all browser storage", async function () {
17
+ (0, cucumber_1.When)("I clear all browser storage", async function () {
16
18
  const { context, page } = this;
17
19
  // Clear cookies
18
20
  await context.clearCookies();
@@ -27,16 +29,16 @@ When("I clear all browser storage", async function () {
27
29
  });
28
30
  this.log("✅ Cleared all cookies and storage");
29
31
  });
30
- When("I set local storage item {string} to {string}", async function (key, value) {
32
+ (0, cucumber_1.When)("I set local storage item {string} to {string}", async function (key, value) {
31
33
  await this.page.evaluate(([k, v]) => localStorage.setItem(k, v), [key, value]);
32
34
  });
33
35
  // When("I clear session storage", async function (this: CustomWorld) {
34
36
  // await this.page.evaluate(() => sessionStorage.clear());
35
37
  // });
36
- When("I clear local storage", async function () {
38
+ (0, cucumber_1.When)("I clear local storage", async function () {
37
39
  await this.page.evaluate(() => localStorage.clear());
38
40
  });
39
- When("I store input text as {string}", async function (alias) {
41
+ (0, cucumber_1.When)("I store input text as {string}", async function (alias) {
40
42
  const activeElementHandle = await this.page.evaluateHandle(() => document.activeElement);
41
43
  const tagName = await activeElementHandle.evaluate((el) => el ? el.tagName.toLowerCase() : "");
42
44
  if (tagName !== "input" && tagName !== "textarea") {
@@ -1,17 +1,19 @@
1
- import { Then } from "@cucumber/cucumber";
2
- import { expect } from "@playwright/test";
3
- import { evaluateFaker } from "../helpers/utils/fakerUtils";
4
- Then("I count {int} elements", async function (expectedCount) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cucumber_1 = require("@cucumber/cucumber");
4
+ const test_1 = require("@playwright/test");
5
+ const fakerUtils_1 = require("../helpers/utils/fakerUtils");
6
+ (0, cucumber_1.Then)("I count {int} elements", async function (expectedCount) {
5
7
  if (!this.elements)
6
8
  throw new Error("No elements found to count");
7
9
  const count = await this.elements.count();
8
10
  await this.page.waitForLoadState("networkidle");
9
- expect(count).toBe(expectedCount);
11
+ (0, test_1.expect)(count).toBe(expectedCount);
10
12
  });
11
13
  /**
12
14
  * THEN: I see button "Submit"
13
15
  */
14
- Then(/^I see button "(.*)"$/, async function (rawText) {
16
+ (0, cucumber_1.Then)(/^I see button "(.*)"$/, async function (rawText) {
15
17
  let buttonText = rawText.startsWith("@")
16
18
  ? this.data[rawText.slice(1)]
17
19
  : rawText;
@@ -23,12 +25,12 @@ Then(/^I see button "(.*)"$/, async function (rawText) {
23
25
  exact: false,
24
26
  });
25
27
  await this.page.waitForLoadState("networkidle");
26
- await expect(button).toBeVisible();
28
+ await (0, test_1.expect)(button).toBeVisible();
27
29
  });
28
30
  /**
29
31
  * THEN: I do not see button "Cancel"
30
32
  */
31
- Then(/^I do not see button "(.*)"$/, async function (rawText) {
33
+ (0, cucumber_1.Then)(/^I do not see button "(.*)"$/, async function (rawText) {
32
34
  let buttonText = rawText.startsWith("@")
33
35
  ? this.data[rawText.slice(1)]
34
36
  : rawText;
@@ -51,7 +53,7 @@ Then(/^I do not see button "(.*)"$/, async function (rawText) {
51
53
  /**
52
54
  * THEN: I see text "Welcome"
53
55
  */
54
- Then("I see text {string}", async function (expected) {
56
+ (0, cucumber_1.Then)("I see text {string}", async function (expected) {
55
57
  const scope = this.getScope(); // ✅ Supports iframe OR main page
56
58
  const locator = scope.locator(`text=${expected}`);
57
59
  await locator.waitFor({ state: "visible", timeout: 5000 });
@@ -60,7 +62,7 @@ Then("I see text {string}", async function (expected) {
60
62
  /**
61
63
  * THEN: I do not see text "Error"
62
64
  */
63
- Then("I do not see text {string}", async function (text) {
65
+ (0, cucumber_1.Then)("I do not see text {string}", async function (text) {
64
66
  await this.page.waitForLoadState("networkidle");
65
67
  const locator = this.page.locator(`:has-text("${text}")`);
66
68
  const count = await locator.count();
@@ -74,7 +76,7 @@ Then("I do not see text {string}", async function (text) {
74
76
  /**
75
77
  * THEN: I see visible text "Dashboard"
76
78
  */
77
- Then("I see visible text {string}", async function (text) {
79
+ (0, cucumber_1.Then)("I see visible text {string}", async function (text) {
78
80
  await this.page.waitForLoadState("networkidle");
79
81
  const locator = this.page.locator(`:text-is("${text}")`);
80
82
  if (!(await locator.first().isVisible())) {
@@ -84,13 +86,13 @@ Then("I see visible text {string}", async function (text) {
84
86
  /**
85
87
  * THEN: I do not see visible text "Logout"
86
88
  */
87
- Then("I do not see visible text {string}", async function (text) {
89
+ (0, cucumber_1.Then)("I do not see visible text {string}", async function (text) {
88
90
  const locator = this.page.locator(`:text-is("${text}")`);
89
91
  if ((await locator.count()) > 0 && (await locator.first().isVisible())) {
90
92
  throw new Error(`Visible text "${text}" should not be visible`);
91
93
  }
92
94
  });
93
- Then("I see value {string}", async function (expected) {
95
+ (0, cucumber_1.Then)("I see value {string}", async function (expected) {
94
96
  if (!this.element)
95
97
  throw new Error("No element selected");
96
98
  const value = await this.element.inputValue();
@@ -98,7 +100,7 @@ Then("I see value {string}", async function (expected) {
98
100
  throw new Error(`Expected value "${expected}", but got "${value}"`);
99
101
  }
100
102
  });
101
- Then("I do not see value {string}", async function (unwanted) {
103
+ (0, cucumber_1.Then)("I do not see value {string}", async function (unwanted) {
102
104
  if (!this.element)
103
105
  throw new Error("No element selected");
104
106
  const value = await this.element.inputValue();
@@ -109,14 +111,14 @@ Then("I do not see value {string}", async function (unwanted) {
109
111
  //
110
112
  // 📃 VISIBLE TEXT ASSERTIONS
111
113
  //
112
- Then(/^I do not see text "(.*)"$/, async function (unexpectedText) {
114
+ (0, cucumber_1.Then)(/^I do not see text "(.*)"$/, async function (unexpectedText) {
113
115
  const el = this.page.getByText(unexpectedText, { exact: true });
114
- await expect(el).toHaveCount(0);
116
+ await (0, test_1.expect)(el).toHaveCount(0);
115
117
  });
116
118
  //
117
119
  // 🆕 Visible Text - Alias for clarity (optional if you want separate steps for naming)
118
120
  //
119
- Then("I see {string} in the element", async function (expected) {
121
+ (0, cucumber_1.Then)("I see {string} in the element", async function (expected) {
120
122
  const element = this.element;
121
123
  if (!element)
122
124
  throw new Error("No element selected");
@@ -128,14 +130,14 @@ Then("I see {string} in the element", async function (expected) {
128
130
  throw new Error(`No data stored for alias "@${alias}"`);
129
131
  }
130
132
  // ✅ Resolve faker syntax
131
- expected = evaluateFaker(expected);
133
+ expected = (0, fakerUtils_1.evaluateFaker)(expected);
132
134
  const textContent = await element.textContent();
133
135
  if (!textContent)
134
136
  throw new Error("Element has no text content");
135
- expect(textContent).toContain(expected);
137
+ (0, test_1.expect)(textContent).toContain(expected);
136
138
  this.log?.(`Verified "${expected}" in element text`);
137
139
  });
138
- Then("I see @{word} in the element", async function (alias) {
140
+ (0, cucumber_1.Then)("I see @{word} in the element", async function (alias) {
139
141
  const storedValue = this.data[alias];
140
142
  if (!storedValue) {
141
143
  throw new Error(`No value found in data storage under alias "@${alias}".`);
@@ -144,10 +146,10 @@ Then("I see @{word} in the element", async function (alias) {
144
146
  throw new Error("No element found. You must get an element before asserting its contents.");
145
147
  }
146
148
  const actualText = (await this.element.textContent())?.trim() || "";
147
- expect(actualText).toContain(storedValue);
149
+ (0, test_1.expect)(actualText).toContain(storedValue);
148
150
  this.log(`Verified element contains value from "@${alias}" = "${storedValue}". Actual: "${actualText}"`);
149
151
  });
150
- Then("I see button {string} is disabled", async function (rawText) {
152
+ (0, cucumber_1.Then)("I see button {string} is disabled", async function (rawText) {
151
153
  // Resolve alias
152
154
  let buttonText = rawText.startsWith("@")
153
155
  ? this.data[rawText.slice(1)]
@@ -159,7 +161,7 @@ Then("I see button {string} is disabled", async function (rawText) {
159
161
  name: buttonText,
160
162
  exact: false,
161
163
  });
162
- await expect(button).toBeVisible({ timeout: 5000 });
164
+ await (0, test_1.expect)(button).toBeVisible({ timeout: 5000 });
163
165
  const isDisabled = await button.isDisabled();
164
166
  if (!isDisabled) {
165
167
  throw new Error(`🚫 Button "${buttonText}" is not disabled as expected.`);
@@ -1,8 +1,10 @@
1
- import { Then } from "@cucumber/cucumber";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cucumber_1 = require("@cucumber/cucumber");
2
4
  /**
3
5
  * THEN: I see cookie "myCookie"
4
6
  */
5
- Then("I see cookie {string}", async function (cookieName) {
7
+ (0, cucumber_1.Then)("I see cookie {string}", async function (cookieName) {
6
8
  const cookies = await this.context.cookies();
7
9
  const cookie = cookies.find((c) => c.name === cookieName);
8
10
  if (!cookie)
@@ -11,7 +13,7 @@ Then("I see cookie {string}", async function (cookieName) {
11
13
  /**
12
14
  * THEN: I do not see cookie "myCookie"
13
15
  */
14
- Then("I do not see cookie {string}", async function (name) {
16
+ (0, cucumber_1.Then)("I do not see cookie {string}", async function (name) {
15
17
  const cookies = await this.context.cookies();
16
18
  const cookie = cookies.find((c) => c.name === name);
17
19
  if (cookie)
@@ -20,7 +22,7 @@ Then("I do not see cookie {string}", async function (name) {
20
22
  /**
21
23
  * THEN: I see cookie "sessionId" has value "abc123"
22
24
  */
23
- Then("I see cookie {string} has value {string}", async function (name, expectedValue) {
25
+ (0, cucumber_1.Then)("I see cookie {string} has value {string}", async function (name, expectedValue) {
24
26
  const cookies = await this.context.cookies();
25
27
  const cookie = cookies.find((c) => c.name === name);
26
28
  if (!cookie)
@@ -32,7 +34,7 @@ Then("I see cookie {string} has value {string}", async function (name, expectedV
32
34
  /**
33
35
  * THEN: I see cookie "token" contains value "auth"
34
36
  */
35
- Then("I see cookie {string} contains value {string}", async function (name, valuePart) {
37
+ (0, cucumber_1.Then)("I see cookie {string} contains value {string}", async function (name, valuePart) {
36
38
  const cookies = await this.context.cookies();
37
39
  const cookie = cookies.find((c) => c.name === name);
38
40
  if (!cookie)