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.
- package/dist/actions/clickSteps.js +35 -33
- package/dist/actions/cookieSteps.js +7 -5
- package/dist/actions/debugSteps.js +5 -3
- package/dist/actions/elementFindSteps.js +50 -48
- package/dist/actions/inputSteps.js +40 -35
- package/dist/actions/interceptionSteps.js +9 -7
- package/dist/actions/miscSteps.js +41 -36
- package/dist/actions/mouseSteps.js +10 -8
- package/dist/actions/scrollSteps.js +7 -5
- package/dist/actions/storageSteps.js +10 -8
- package/dist/assertions/buttonAndTextVisibilitySteps.js +25 -23
- package/dist/assertions/cookieSteps.js +7 -5
- package/dist/assertions/elementSteps.js +24 -22
- package/dist/assertions/formInputSteps.js +28 -26
- package/dist/assertions/interceptionRequestsSteps.js +27 -25
- package/dist/assertions/locationSteps.js +17 -15
- package/dist/assertions/roleTestIdSteps.js +12 -10
- package/dist/assertions/semanticSteps.js +9 -7
- package/dist/assertions/storageSteps.js +23 -18
- package/dist/assertions/visualSteps.js +41 -36
- package/dist/custom_setups/globalLogin.js +10 -5
- package/dist/custom_setups/loginHooks.js +30 -25
- package/dist/helpers/checkPeerDeps.d.ts +1 -0
- package/dist/helpers/checkPeerDeps.js +19 -0
- package/dist/helpers/compareSnapshots.js +15 -9
- package/dist/helpers/hooks.js +73 -35
- package/dist/helpers/utils/fakerUtils.js +32 -26
- package/dist/helpers/utils/index.js +19 -3
- package/dist/helpers/utils/optionsUtils.js +18 -8
- package/dist/helpers/utils/resolveUtils.js +19 -11
- package/dist/helpers/world.js +45 -8
- package/dist/iframes/frames.js +4 -2
- package/dist/index.js +43 -27
- package/dist/register.js +9 -1
- package/package.json +24 -8
|
@@ -1,70 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cucumber_1 = require("@cucumber/cucumber");
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
3
5
|
//
|
|
4
6
|
// ✅ ELEMENT EXISTS
|
|
5
7
|
//
|
|
6
|
-
Then(/^I see element "([^"]+)" exists$/, async function (selector) {
|
|
8
|
+
(0, cucumber_1.Then)(/^I see element "([^"]+)" exists$/, async function (selector) {
|
|
7
9
|
const el = await this.page.locator(selector);
|
|
8
|
-
await expect(el).toHaveCount(1);
|
|
10
|
+
await (0, test_1.expect)(el).toHaveCount(1);
|
|
9
11
|
});
|
|
10
|
-
Then("I see element exists", async function () {
|
|
12
|
+
(0, cucumber_1.Then)("I see element exists", async function () {
|
|
11
13
|
if (!this.element)
|
|
12
14
|
throw new Error("No element stored in context");
|
|
13
15
|
const count = (await this.element.count?.()) ?? 1;
|
|
14
16
|
if (count === 0)
|
|
15
17
|
throw new Error("Element does not exist");
|
|
16
18
|
});
|
|
17
|
-
Then("I see element does not exist", async function () {
|
|
19
|
+
(0, cucumber_1.Then)("I see element does not exist", async function () {
|
|
18
20
|
if (!this.element)
|
|
19
21
|
throw new Error("No element stored in context");
|
|
20
22
|
const count = (await this.element.count?.()) ?? 1;
|
|
21
23
|
if (count > 0)
|
|
22
24
|
throw new Error("Element exists but should not");
|
|
23
25
|
});
|
|
24
|
-
Then("I see element is visible", async function () {
|
|
26
|
+
(0, cucumber_1.Then)("I see element is visible", async function () {
|
|
25
27
|
if (!this.element)
|
|
26
28
|
throw new Error("No element in context");
|
|
27
29
|
const isVisible = await this.element.isVisible();
|
|
28
30
|
if (!isVisible)
|
|
29
31
|
throw new Error("Element is not visible");
|
|
30
32
|
});
|
|
31
|
-
Then("I see element is not visible", async function () {
|
|
33
|
+
(0, cucumber_1.Then)("I see element is not visible", async function () {
|
|
32
34
|
if (!this.element)
|
|
33
35
|
throw new Error("No element in context");
|
|
34
36
|
const isVisible = await this.element.isVisible();
|
|
35
37
|
if (isVisible)
|
|
36
38
|
throw new Error("Element is visible but should not be");
|
|
37
39
|
});
|
|
38
|
-
Then(/^I see element "([^"]+)" does not exist$/, async function (selector) {
|
|
40
|
+
(0, cucumber_1.Then)(/^I see element "([^"]+)" does not exist$/, async function (selector) {
|
|
39
41
|
const el = await this.page.locator(selector);
|
|
40
|
-
await expect(el).toHaveCount(0);
|
|
42
|
+
await (0, test_1.expect)(el).toHaveCount(0);
|
|
41
43
|
});
|
|
42
44
|
//
|
|
43
45
|
// 👁️ ELEMENT VISIBILITY
|
|
44
46
|
//
|
|
45
|
-
Then(/^I see element "([^"]+)" is visible$/, async function (selector) {
|
|
47
|
+
(0, cucumber_1.Then)(/^I see element "([^"]+)" is visible$/, async function (selector) {
|
|
46
48
|
const el = this.page.locator(selector);
|
|
47
|
-
await expect(el).toBeVisible();
|
|
49
|
+
await (0, test_1.expect)(el).toBeVisible();
|
|
48
50
|
});
|
|
49
|
-
Then(/^I see element "([^"]+)" is not visible$/, async function (selector) {
|
|
51
|
+
(0, cucumber_1.Then)(/^I see element "([^"]+)" is not visible$/, async function (selector) {
|
|
50
52
|
const el = this.page.locator(selector);
|
|
51
|
-
await expect(el).not.toBeVisible();
|
|
53
|
+
await (0, test_1.expect)(el).not.toBeVisible();
|
|
52
54
|
});
|
|
53
55
|
//
|
|
54
56
|
// 🔎 ATTRIBUTE ASSERTIONS
|
|
55
57
|
//
|
|
56
|
-
Then(/^I see element "([^"]+)" attribute "([^"]+)" equals "(.*)"$/, async function (selector, attribute, expected) {
|
|
58
|
+
(0, cucumber_1.Then)(/^I see element "([^"]+)" attribute "([^"]+)" equals "(.*)"$/, async function (selector, attribute, expected) {
|
|
57
59
|
const el = this.page.locator(selector);
|
|
58
|
-
await expect(el).toHaveAttribute(attribute, expected);
|
|
60
|
+
await (0, test_1.expect)(el).toHaveAttribute(attribute, expected);
|
|
59
61
|
});
|
|
60
|
-
Then("I see element has attribute {string}", async function (attr) {
|
|
62
|
+
(0, cucumber_1.Then)("I see element has attribute {string}", async function (attr) {
|
|
61
63
|
if (!this.element)
|
|
62
64
|
throw new Error("No element in context");
|
|
63
65
|
const value = await this.element.getAttribute(attr);
|
|
64
66
|
if (value === null)
|
|
65
67
|
throw new Error(`Attribute "${attr}" not found`);
|
|
66
68
|
});
|
|
67
|
-
Then("I see element attribute {string} contains {string}", async function (attr, part) {
|
|
69
|
+
(0, cucumber_1.Then)("I see element attribute {string} contains {string}", async function (attr, part) {
|
|
68
70
|
if (!this.element)
|
|
69
71
|
throw new Error("No element in context");
|
|
70
72
|
const value = await this.element.getAttribute(attr);
|
|
@@ -72,11 +74,11 @@ Then("I see element attribute {string} contains {string}", async function (attr,
|
|
|
72
74
|
throw new Error(`Attribute "${attr}" does not contain "${part}". Got: "${value}"`);
|
|
73
75
|
}
|
|
74
76
|
});
|
|
75
|
-
Then(/^I see element "([^"]+)" attribute "([^"]+)" contains "(.*)"$/, async function (selector, attribute, substring) {
|
|
77
|
+
(0, cucumber_1.Then)(/^I see element "([^"]+)" attribute "([^"]+)" contains "(.*)"$/, async function (selector, attribute, substring) {
|
|
76
78
|
const attr = await this.page.locator(selector).getAttribute(attribute);
|
|
77
|
-
expect(attr?.includes(substring)).toBeTruthy();
|
|
79
|
+
(0, test_1.expect)(attr?.includes(substring)).toBeTruthy();
|
|
78
80
|
});
|
|
79
|
-
Then(/^I see element "([^"]+)" has attribute "([^"]+)"$/, async function (selector, attribute) {
|
|
81
|
+
(0, cucumber_1.Then)(/^I see element "([^"]+)" has attribute "([^"]+)"$/, async function (selector, attribute) {
|
|
80
82
|
const attr = await this.page.locator(selector).getAttribute(attribute);
|
|
81
|
-
expect(attr).not.toBeNull();
|
|
83
|
+
(0, test_1.expect)(attr).not.toBeNull();
|
|
82
84
|
});
|
|
@@ -1,43 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cucumber_1 = require("@cucumber/cucumber");
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
3
5
|
//
|
|
4
6
|
// 🧾 INPUT VALUES
|
|
5
7
|
//
|
|
6
|
-
Then(/^I see input "([^"]+)" has value "(.*)"$/, async function (selector, value) {
|
|
8
|
+
(0, cucumber_1.Then)(/^I see input "([^"]+)" has value "(.*)"$/, async function (selector, value) {
|
|
7
9
|
const el = this.page.locator(selector);
|
|
8
|
-
await expect(el).toHaveValue(value);
|
|
10
|
+
await (0, test_1.expect)(el).toHaveValue(value);
|
|
9
11
|
});
|
|
10
|
-
Then("I see input value {string}", async function (expected) {
|
|
12
|
+
(0, cucumber_1.Then)("I see input value {string}", async function (expected) {
|
|
11
13
|
if (!this.element)
|
|
12
14
|
throw new Error("No element stored in context");
|
|
13
15
|
const value = await this.element.inputValue();
|
|
14
|
-
expect(value).toBe(expected);
|
|
16
|
+
(0, test_1.expect)(value).toBe(expected);
|
|
15
17
|
});
|
|
16
|
-
Then("I see input value contains {string}", async function (part) {
|
|
18
|
+
(0, cucumber_1.Then)("I see input value contains {string}", async function (part) {
|
|
17
19
|
if (!this.element)
|
|
18
20
|
throw new Error("No element stored in context");
|
|
19
21
|
const value = await this.element.inputValue();
|
|
20
|
-
expect(value).toContain(part);
|
|
22
|
+
(0, test_1.expect)(value).toContain(part);
|
|
21
23
|
});
|
|
22
|
-
Then(/^I see input "([^"]+)" value contains "(.*)"$/, async function (selector, partial) {
|
|
24
|
+
(0, cucumber_1.Then)(/^I see input "([^"]+)" value contains "(.*)"$/, async function (selector, partial) {
|
|
23
25
|
const val = await this.page.locator(selector).inputValue();
|
|
24
|
-
expect(val).toContain(partial);
|
|
26
|
+
(0, test_1.expect)(val).toContain(partial);
|
|
25
27
|
});
|
|
26
28
|
//
|
|
27
29
|
// 📝 TEXTAREA VALUES
|
|
28
30
|
//
|
|
29
|
-
Then(/^I see textarea "([^"]+)" has value "(.*)"$/, async function (selector, value) {
|
|
31
|
+
(0, cucumber_1.Then)(/^I see textarea "([^"]+)" has value "(.*)"$/, async function (selector, value) {
|
|
30
32
|
const el = this.page.locator(selector);
|
|
31
|
-
await expect(el).toHaveValue(value);
|
|
33
|
+
await (0, test_1.expect)(el).toHaveValue(value);
|
|
32
34
|
});
|
|
33
|
-
Then("I see textarea value {string}", async function (expected) {
|
|
35
|
+
(0, cucumber_1.Then)("I see textarea value {string}", async function (expected) {
|
|
34
36
|
if (!this.element)
|
|
35
37
|
throw new Error("No textarea selected");
|
|
36
38
|
const value = await this.element.inputValue();
|
|
37
39
|
if (value !== expected)
|
|
38
40
|
throw new Error(`Expected "${expected}", got "${value}"`);
|
|
39
41
|
});
|
|
40
|
-
Then("I see textarea value contains {string}", async function (part) {
|
|
42
|
+
(0, cucumber_1.Then)("I see textarea value contains {string}", async function (part) {
|
|
41
43
|
if (!this.element)
|
|
42
44
|
throw new Error("No textarea selected");
|
|
43
45
|
const value = await this.element.inputValue();
|
|
@@ -45,41 +47,41 @@ Then("I see textarea value contains {string}", async function (part) {
|
|
|
45
47
|
throw new Error(`Textarea does not contain "${part}". Got: "${value}"`);
|
|
46
48
|
}
|
|
47
49
|
});
|
|
48
|
-
Then(/^I see textarea "([^"]+)" value contains "(.*)"$/, async function (selector, partial) {
|
|
50
|
+
(0, cucumber_1.Then)(/^I see textarea "([^"]+)" value contains "(.*)"$/, async function (selector, partial) {
|
|
49
51
|
const val = await this.page.locator(selector).inputValue();
|
|
50
|
-
expect(val).toContain(partial);
|
|
52
|
+
(0, test_1.expect)(val).toContain(partial);
|
|
51
53
|
});
|
|
52
54
|
//
|
|
53
55
|
// ✅ GENERIC VALUE MATCHING
|
|
54
56
|
//
|
|
55
|
-
Then(/^I see value "(.*)" in "([^"]+)"$/, async function (value, selector) {
|
|
57
|
+
(0, cucumber_1.Then)(/^I see value "(.*)" in "([^"]+)"$/, async function (value, selector) {
|
|
56
58
|
const el = this.page.locator(selector);
|
|
57
|
-
await expect(el).toHaveValue(value);
|
|
59
|
+
await (0, test_1.expect)(el).toHaveValue(value);
|
|
58
60
|
});
|
|
59
|
-
Then(/^I do not see value "(.*)" in "([^"]+)"$/, async function (value, selector) {
|
|
61
|
+
(0, cucumber_1.Then)(/^I do not see value "(.*)" in "([^"]+)"$/, async function (value, selector) {
|
|
60
62
|
const actual = await this.page.locator(selector).inputValue();
|
|
61
|
-
expect(actual).not.toBe(value);
|
|
63
|
+
(0, test_1.expect)(actual).not.toBe(value);
|
|
62
64
|
});
|
|
63
65
|
//
|
|
64
66
|
// ⬇️ OPTION IN SELECT
|
|
65
67
|
//
|
|
66
|
-
Then(/^I see option "(.*)"$/, async function (optionText) {
|
|
68
|
+
(0, cucumber_1.Then)(/^I see option "(.*)"$/, async function (optionText) {
|
|
67
69
|
const el = this.page.locator(`option`, { hasText: optionText });
|
|
68
|
-
await expect(el).toHaveCount(1);
|
|
70
|
+
await (0, test_1.expect)(el).toHaveCount(1);
|
|
69
71
|
});
|
|
70
|
-
Then("I see option {string}", async function (optionText) {
|
|
72
|
+
(0, cucumber_1.Then)("I see option {string}", async function (optionText) {
|
|
71
73
|
const option = this.page.locator("option", { hasText: optionText });
|
|
72
74
|
if (!(await option.isVisible())) {
|
|
73
75
|
throw new Error(`Option "${optionText}" not visible`);
|
|
74
76
|
}
|
|
75
77
|
});
|
|
76
|
-
Then("I do not see option {string}", async function (optionText) {
|
|
78
|
+
(0, cucumber_1.Then)("I do not see option {string}", async function (optionText) {
|
|
77
79
|
const option = this.page.locator("option", { hasText: optionText });
|
|
78
80
|
if ((await option.count()) > 0 && (await option.first().isVisible())) {
|
|
79
81
|
throw new Error(`Option "${optionText}" is visible but should not be`);
|
|
80
82
|
}
|
|
81
83
|
});
|
|
82
|
-
Then(/^I do not see option "(.*)"$/, async function (optionText) {
|
|
84
|
+
(0, cucumber_1.Then)(/^I do not see option "(.*)"$/, async function (optionText) {
|
|
83
85
|
const el = this.page.locator(`option`, { hasText: optionText });
|
|
84
|
-
await expect(el).toHaveCount(0);
|
|
86
|
+
await (0, test_1.expect)(el).toHaveCount(0);
|
|
85
87
|
});
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cucumber_1 = require("@cucumber/cucumber");
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
3
5
|
// Accessing the Last Response
|
|
4
|
-
Then("I should see response status {int}", function (expectedStatus) {
|
|
5
|
-
expect(this.data.lastResponse?.status).toBe(expectedStatus);
|
|
6
|
+
(0, cucumber_1.Then)("I should see response status {int}", function (expectedStatus) {
|
|
7
|
+
(0, test_1.expect)(this.data.lastResponse?.status).toBe(expectedStatus);
|
|
6
8
|
this.log(`Verified response status is ${expectedStatus}`);
|
|
7
9
|
});
|
|
8
|
-
Then("I should see response body contains {string}", function (expectedText) {
|
|
9
|
-
expect(this.data.lastResponse?.body).toContain(expectedText);
|
|
10
|
+
(0, cucumber_1.Then)("I should see response body contains {string}", function (expectedText) {
|
|
11
|
+
(0, test_1.expect)(this.data.lastResponse?.body).toContain(expectedText);
|
|
10
12
|
this.log(`Verified response body contains "${expectedText}"`);
|
|
11
13
|
});
|
|
12
|
-
Then("I see response body {string}", async function (expected) {
|
|
14
|
+
(0, cucumber_1.Then)("I see response body {string}", async function (expected) {
|
|
13
15
|
const res = this.data.lastResponse;
|
|
14
16
|
const body = await res.text();
|
|
15
17
|
if (body !== expected)
|
|
16
18
|
throw new Error(`Expected body "${expected}", got "${body}"`);
|
|
17
19
|
});
|
|
18
|
-
Then("I see response body contains {string}", async function (part) {
|
|
20
|
+
(0, cucumber_1.Then)("I see response body contains {string}", async function (part) {
|
|
19
21
|
const res = this.data.lastResponse;
|
|
20
22
|
const body = await res.text();
|
|
21
23
|
if (!body.includes(part))
|
|
22
24
|
throw new Error(`Body does not contain "${part}"`);
|
|
23
25
|
});
|
|
24
|
-
Then("I see response body matches JSON schema {string}", async function (schemaPath) {
|
|
26
|
+
(0, cucumber_1.Then)("I see response body matches JSON schema {string}", async function (schemaPath) {
|
|
25
27
|
const res = this.data.lastResponse;
|
|
26
28
|
const body = await res.text();
|
|
27
29
|
const schema = require(schemaPath); // Assuming schema is a JSON file
|
|
@@ -33,7 +35,7 @@ Then("I see response body matches JSON schema {string}", async function (schemaP
|
|
|
33
35
|
throw new Error(`Response body does not match schema: ${ajv.errorsText(validate.errors)}`);
|
|
34
36
|
}
|
|
35
37
|
});
|
|
36
|
-
Then("I see response header {string} equals {string}", async function (headerName, expectedValue) {
|
|
38
|
+
(0, cucumber_1.Then)("I see response header {string} equals {string}", async function (headerName, expectedValue) {
|
|
37
39
|
const res = this.data.lastResponse;
|
|
38
40
|
const headerValue = res.headers()[headerName.toLowerCase()];
|
|
39
41
|
if (headerValue !== expectedValue) {
|
|
@@ -41,7 +43,7 @@ Then("I see response header {string} equals {string}", async function (headerNam
|
|
|
41
43
|
}
|
|
42
44
|
this.log(`Verified response header "${headerName}" equals "${expectedValue}"`);
|
|
43
45
|
});
|
|
44
|
-
Then("I see response header {string} contains {string}", async function (headerName, expectedValue) {
|
|
46
|
+
(0, cucumber_1.Then)("I see response header {string} contains {string}", async function (headerName, expectedValue) {
|
|
45
47
|
const res = this.data.lastResponse;
|
|
46
48
|
const headerValue = res.headers()[headerName.toLowerCase()];
|
|
47
49
|
if (!headerValue || !headerValue.includes(expectedValue)) {
|
|
@@ -49,7 +51,7 @@ Then("I see response header {string} contains {string}", async function (headerN
|
|
|
49
51
|
}
|
|
50
52
|
this.log(`Verified response header "${headerName}" contains "${expectedValue}"`);
|
|
51
53
|
});
|
|
52
|
-
Then("I see response header {string} does not contain {string}", async function (headerName, unexpectedValue) {
|
|
54
|
+
(0, cucumber_1.Then)("I see response header {string} does not contain {string}", async function (headerName, unexpectedValue) {
|
|
53
55
|
const res = this.data.lastResponse;
|
|
54
56
|
const headerValue = res.headers()[headerName.toLowerCase()];
|
|
55
57
|
if (headerValue && headerValue.includes(unexpectedValue)) {
|
|
@@ -57,7 +59,7 @@ Then("I see response header {string} does not contain {string}", async function
|
|
|
57
59
|
}
|
|
58
60
|
this.log(`Verified response header "${headerName}" does not contain "${unexpectedValue}"`);
|
|
59
61
|
});
|
|
60
|
-
Then("I see response header {string} does not equal {string}", async function (headerName, unexpectedValue) {
|
|
62
|
+
(0, cucumber_1.Then)("I see response header {string} does not equal {string}", async function (headerName, unexpectedValue) {
|
|
61
63
|
const res = this.data.lastResponse;
|
|
62
64
|
const headerValue = res.headers()[headerName.toLowerCase()];
|
|
63
65
|
if (headerValue === unexpectedValue) {
|
|
@@ -65,7 +67,7 @@ Then("I see response header {string} does not equal {string}", async function (h
|
|
|
65
67
|
}
|
|
66
68
|
this.log(`Verified response header "${headerName}" does not equal "${unexpectedValue}"`);
|
|
67
69
|
});
|
|
68
|
-
Then("I see response header {string} exists", async function (headerName) {
|
|
70
|
+
(0, cucumber_1.Then)("I see response header {string} exists", async function (headerName) {
|
|
69
71
|
const res = this.data.lastResponse;
|
|
70
72
|
const headerValue = res.headers()[headerName.toLowerCase()];
|
|
71
73
|
if (!headerValue) {
|
|
@@ -73,7 +75,7 @@ Then("I see response header {string} exists", async function (headerName) {
|
|
|
73
75
|
}
|
|
74
76
|
this.log(`Verified response header "${headerName}" exists`);
|
|
75
77
|
});
|
|
76
|
-
Then("I see response header {string} does not exist", async function (headerName) {
|
|
78
|
+
(0, cucumber_1.Then)("I see response header {string} does not exist", async function (headerName) {
|
|
77
79
|
const res = this.data.lastResponse;
|
|
78
80
|
const headerValue = res.headers()[headerName.toLowerCase()];
|
|
79
81
|
if (headerValue) {
|
|
@@ -81,7 +83,7 @@ Then("I see response header {string} does not exist", async function (headerName
|
|
|
81
83
|
}
|
|
82
84
|
this.log(`Verified response header "${headerName}" does not exist`);
|
|
83
85
|
});
|
|
84
|
-
Then("I see response status {int}", async function (status) {
|
|
86
|
+
(0, cucumber_1.Then)("I see response status {int}", async function (status) {
|
|
85
87
|
const res = this.data.lastResponse;
|
|
86
88
|
if (!res)
|
|
87
89
|
throw new Error("No response available");
|
|
@@ -89,7 +91,7 @@ Then("I see response status {int}", async function (status) {
|
|
|
89
91
|
if (actual !== status)
|
|
90
92
|
throw new Error(`Expected status ${status}, got ${actual}`);
|
|
91
93
|
});
|
|
92
|
-
Then("I see response status is not {int}", async function (status) {
|
|
94
|
+
(0, cucumber_1.Then)("I see response status is not {int}", async function (status) {
|
|
93
95
|
const res = this.data.lastResponse;
|
|
94
96
|
if (!res)
|
|
95
97
|
throw new Error("No response available");
|
|
@@ -97,7 +99,7 @@ Then("I see response status is not {int}", async function (status) {
|
|
|
97
99
|
if (actual === status)
|
|
98
100
|
throw new Error(`Expected status not to be ${status}, but it is`);
|
|
99
101
|
});
|
|
100
|
-
Then("I see response body matches JSON schema", async function (schema) {
|
|
102
|
+
(0, cucumber_1.Then)("I see response body matches JSON schema", async function (schema) {
|
|
101
103
|
const res = this.data.lastResponse;
|
|
102
104
|
if (!res)
|
|
103
105
|
throw new Error("No response available");
|
|
@@ -111,7 +113,7 @@ Then("I see response body matches JSON schema", async function (schema) {
|
|
|
111
113
|
}
|
|
112
114
|
this.log(`Response body matches JSON schema`);
|
|
113
115
|
});
|
|
114
|
-
Then("I see response body is empty", async function () {
|
|
116
|
+
(0, cucumber_1.Then)("I see response body is empty", async function () {
|
|
115
117
|
const res = this.data.lastResponse;
|
|
116
118
|
if (!res)
|
|
117
119
|
throw new Error("No response available");
|
|
@@ -121,7 +123,7 @@ Then("I see response body is empty", async function () {
|
|
|
121
123
|
}
|
|
122
124
|
this.log(`Verified response body is empty`);
|
|
123
125
|
});
|
|
124
|
-
Then("I see response body is not empty", async function () {
|
|
126
|
+
(0, cucumber_1.Then)("I see response body is not empty", async function () {
|
|
125
127
|
const res = this.data.lastResponse;
|
|
126
128
|
if (!res)
|
|
127
129
|
throw new Error("No response available");
|
|
@@ -131,7 +133,7 @@ Then("I see response body is not empty", async function () {
|
|
|
131
133
|
}
|
|
132
134
|
this.log(`Verified response body is not empty`);
|
|
133
135
|
});
|
|
134
|
-
Then("I see response body matches {string}", async function (expected) {
|
|
136
|
+
(0, cucumber_1.Then)("I see response body matches {string}", async function (expected) {
|
|
135
137
|
const res = this.data.lastResponse;
|
|
136
138
|
if (!res)
|
|
137
139
|
throw new Error("No response available");
|
|
@@ -141,7 +143,7 @@ Then("I see response body matches {string}", async function (expected) {
|
|
|
141
143
|
}
|
|
142
144
|
this.log(`Verified response body matches: ${expected}`);
|
|
143
145
|
});
|
|
144
|
-
Then("I see response body contains {string}", async function (part) {
|
|
146
|
+
(0, cucumber_1.Then)("I see response body contains {string}", async function (part) {
|
|
145
147
|
const res = this.data.lastResponse;
|
|
146
148
|
if (!res)
|
|
147
149
|
throw new Error("No response available");
|
|
@@ -151,7 +153,7 @@ Then("I see response body contains {string}", async function (part) {
|
|
|
151
153
|
}
|
|
152
154
|
this.log(`Verified response body contains: ${part}`);
|
|
153
155
|
});
|
|
154
|
-
Then("I see response body does not contain {string}", async function (part) {
|
|
156
|
+
(0, cucumber_1.Then)("I see response body does not contain {string}", async function (part) {
|
|
155
157
|
const res = this.data.lastResponse;
|
|
156
158
|
if (!res)
|
|
157
159
|
throw new Error("No response available");
|
|
@@ -161,7 +163,7 @@ Then("I see response body does not contain {string}", async function (part) {
|
|
|
161
163
|
}
|
|
162
164
|
this.log(`Verified response body does not contain: ${part}`);
|
|
163
165
|
});
|
|
164
|
-
Then("I see response body is JSON", async function () {
|
|
166
|
+
(0, cucumber_1.Then)("I see response body is JSON", async function () {
|
|
165
167
|
const res = this.data.lastResponse;
|
|
166
168
|
if (!res)
|
|
167
169
|
throw new Error("No response available");
|
|
@@ -179,7 +181,7 @@ Then("I see response body is JSON", async function () {
|
|
|
179
181
|
}
|
|
180
182
|
}
|
|
181
183
|
});
|
|
182
|
-
Then("I see response body is not JSON", async function () {
|
|
184
|
+
(0, cucumber_1.Then)("I see response body is not JSON", async function () {
|
|
183
185
|
const res = this.data.lastResponse;
|
|
184
186
|
if (!res)
|
|
185
187
|
throw new Error("No response available");
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cucumber_1 = require("@cucumber/cucumber");
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
3
5
|
//
|
|
4
6
|
// 🌐 URL
|
|
5
7
|
//
|
|
6
|
-
Then("I see URL {string}", async function (expected) {
|
|
8
|
+
(0, cucumber_1.Then)("I see URL {string}", async function (expected) {
|
|
7
9
|
const url = this.page.url();
|
|
8
|
-
expect(url).toBe(expected);
|
|
10
|
+
(0, test_1.expect)(url).toBe(expected);
|
|
9
11
|
});
|
|
10
|
-
Then("I do not see URL {string}", async function (notExpected) {
|
|
12
|
+
(0, cucumber_1.Then)("I do not see URL {string}", async function (notExpected) {
|
|
11
13
|
const url = this.page.url();
|
|
12
14
|
if (url === notExpected)
|
|
13
15
|
throw new Error(`Expected not to be on URL "${notExpected}"`);
|
|
14
16
|
});
|
|
15
|
-
Then("I see URL contains {string}", async function (expected) {
|
|
17
|
+
(0, cucumber_1.Then)("I see URL contains {string}", async function (expected) {
|
|
16
18
|
const url = this.page.url();
|
|
17
|
-
expect(url).toContain(expected);
|
|
19
|
+
(0, test_1.expect)(url).toContain(expected);
|
|
18
20
|
});
|
|
19
|
-
Then("I do not see URL contains {string}", async function (notExpected) {
|
|
21
|
+
(0, cucumber_1.Then)("I do not see URL contains {string}", async function (notExpected) {
|
|
20
22
|
const url = this.page.url();
|
|
21
23
|
if (url.includes(notExpected)) {
|
|
22
24
|
throw new Error(`URL should not contain "${notExpected}", but got "${url}"`);
|
|
@@ -25,43 +27,43 @@ Then("I do not see URL contains {string}", async function (notExpected) {
|
|
|
25
27
|
//
|
|
26
28
|
// 📍 LOCATION PARTS
|
|
27
29
|
//
|
|
28
|
-
Then("I see location {string}", async function (expected) {
|
|
30
|
+
(0, cucumber_1.Then)("I see location {string}", async function (expected) {
|
|
29
31
|
const location = await this.page.evaluate(() => window.location.href);
|
|
30
32
|
if (location !== expected) {
|
|
31
33
|
throw new Error(`Expected location to be "${expected}", but got "${location}"`);
|
|
32
34
|
}
|
|
33
35
|
});
|
|
34
|
-
Then("I see pathname {string}", async function (expected) {
|
|
36
|
+
(0, cucumber_1.Then)("I see pathname {string}", async function (expected) {
|
|
35
37
|
const pathname = await this.page.evaluate(() => window.location.pathname);
|
|
36
38
|
if (pathname !== expected) {
|
|
37
39
|
throw new Error(`Expected pathname "${expected}", but got "${pathname}"`);
|
|
38
40
|
}
|
|
39
41
|
});
|
|
40
|
-
Then("I see pathname contains {string}", async function (part) {
|
|
42
|
+
(0, cucumber_1.Then)("I see pathname contains {string}", async function (part) {
|
|
41
43
|
const pathname = await this.page.evaluate(() => window.location.pathname);
|
|
42
44
|
if (!pathname.includes(part)) {
|
|
43
45
|
throw new Error(`Pathname does not contain "${part}". Got: "${pathname}"`);
|
|
44
46
|
}
|
|
45
47
|
});
|
|
46
|
-
Then("I see hash {string}", async function (expected) {
|
|
48
|
+
(0, cucumber_1.Then)("I see hash {string}", async function (expected) {
|
|
47
49
|
const hash = await this.page.evaluate(() => window.location.hash);
|
|
48
50
|
if (hash !== expected) {
|
|
49
51
|
throw new Error(`Expected hash "${expected}", but got "${hash}"`);
|
|
50
52
|
}
|
|
51
53
|
});
|
|
52
|
-
Then("I see hash contains {string}", async function (part) {
|
|
54
|
+
(0, cucumber_1.Then)("I see hash contains {string}", async function (part) {
|
|
53
55
|
const hash = await this.page.evaluate(() => window.location.hash);
|
|
54
56
|
if (!hash.includes(part)) {
|
|
55
57
|
throw new Error(`Expected hash to contain "${part}", but got "${hash}"`);
|
|
56
58
|
}
|
|
57
59
|
});
|
|
58
|
-
Then("I see search {string}", async function (expected) {
|
|
60
|
+
(0, cucumber_1.Then)("I see search {string}", async function (expected) {
|
|
59
61
|
const search = await this.page.evaluate(() => window.location.search);
|
|
60
62
|
if (search !== expected) {
|
|
61
63
|
throw new Error(`Expected search to be "${expected}", but got "${search}"`);
|
|
62
64
|
}
|
|
63
65
|
});
|
|
64
|
-
Then("I see search contains {string}", async function (part) {
|
|
66
|
+
(0, cucumber_1.Then)("I see search contains {string}", async function (part) {
|
|
65
67
|
const search = await this.page.evaluate(() => window.location.search);
|
|
66
68
|
if (!search.includes(part)) {
|
|
67
69
|
throw new Error(`Search does not contain "${part}". Got: "${search}"`);
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cucumber_1 = require("@cucumber/cucumber");
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
3
5
|
//
|
|
4
6
|
// 🧩 ROLE-BASED ELEMENTS
|
|
5
7
|
//
|
|
6
|
-
Then(/^I see role "(.*)" with name "(.*)"$/, async function (role, name) {
|
|
8
|
+
(0, cucumber_1.Then)(/^I see role "(.*)" with name "(.*)"$/, async function (role, name) {
|
|
7
9
|
const el = this.page.getByRole(role, { name, exact: true });
|
|
8
|
-
await expect(el).toBeVisible();
|
|
10
|
+
await (0, test_1.expect)(el).toBeVisible();
|
|
9
11
|
});
|
|
10
|
-
Then(/^I do not see role "(.*)" with name "(.*)"$/, async function (role, name) {
|
|
12
|
+
(0, cucumber_1.Then)(/^I do not see role "(.*)" with name "(.*)"$/, async function (role, name) {
|
|
11
13
|
const el = this.page.getByRole(role, { name, exact: true });
|
|
12
|
-
await expect(el).toHaveCount(0);
|
|
14
|
+
await (0, test_1.expect)(el).toHaveCount(0);
|
|
13
15
|
});
|
|
14
16
|
//
|
|
15
17
|
// 🏷️ TEST ID-BASED ELEMENTS
|
|
16
18
|
//
|
|
17
|
-
Then(/^I see testid "(.*)"$/, async function (testId) {
|
|
19
|
+
(0, cucumber_1.Then)(/^I see testid "(.*)"$/, async function (testId) {
|
|
18
20
|
const el = this.page.getByTestId(testId);
|
|
19
|
-
await expect(el).toBeVisible();
|
|
21
|
+
await (0, test_1.expect)(el).toBeVisible();
|
|
20
22
|
});
|
|
21
|
-
Then(/^I do not see testid "(.*)"$/, async function (testId) {
|
|
23
|
+
(0, cucumber_1.Then)(/^I do not see testid "(.*)"$/, async function (testId) {
|
|
22
24
|
const el = this.page.getByTestId(testId);
|
|
23
|
-
await expect(el).toHaveCount(0);
|
|
25
|
+
await (0, test_1.expect)(el).toHaveCount(0);
|
|
24
26
|
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cucumber_1 = require("@cucumber/cucumber");
|
|
2
4
|
//
|
|
3
5
|
// 🧠 HEADINGS
|
|
4
6
|
//
|
|
5
|
-
Then("I see heading {string}", async function (text) {
|
|
7
|
+
(0, cucumber_1.Then)("I see heading {string}", async function (text) {
|
|
6
8
|
const heading = await this.page
|
|
7
9
|
.locator("h1, h2, h3, h4, h5, h6", { hasText: text })
|
|
8
10
|
.first();
|
|
@@ -10,7 +12,7 @@ Then("I see heading {string}", async function (text) {
|
|
|
10
12
|
throw new Error(`Heading "${text}" not found or not visible`);
|
|
11
13
|
}
|
|
12
14
|
});
|
|
13
|
-
Then("I do not see heading {string}", async function (text) {
|
|
15
|
+
(0, cucumber_1.Then)("I do not see heading {string}", async function (text) {
|
|
14
16
|
const heading = this.page.locator("h1, h2, h3, h4, h5, h6", {
|
|
15
17
|
hasText: text,
|
|
16
18
|
});
|
|
@@ -23,13 +25,13 @@ Then("I do not see heading {string}", async function (text) {
|
|
|
23
25
|
//
|
|
24
26
|
// 🏷️ LABELS
|
|
25
27
|
//
|
|
26
|
-
Then("I see label {string}", async function (text) {
|
|
28
|
+
(0, cucumber_1.Then)("I see label {string}", async function (text) {
|
|
27
29
|
const label = this.page.getByLabel(text);
|
|
28
30
|
if (!(await label.isVisible())) {
|
|
29
31
|
throw new Error(`Label "${text}" not visible`);
|
|
30
32
|
}
|
|
31
33
|
});
|
|
32
|
-
Then("I do not see label {string}", async function (text) {
|
|
34
|
+
(0, cucumber_1.Then)("I do not see label {string}", async function (text) {
|
|
33
35
|
const label = this.page.getByLabel(text);
|
|
34
36
|
if ((await label.count()) > 0 && (await label.first().isVisible())) {
|
|
35
37
|
throw new Error(`Label "${text}" is visible but should not be`);
|
|
@@ -38,13 +40,13 @@ Then("I do not see label {string}", async function (text) {
|
|
|
38
40
|
//
|
|
39
41
|
// 🔗 LINKS
|
|
40
42
|
//
|
|
41
|
-
Then("I see link {string}", async function (text) {
|
|
43
|
+
(0, cucumber_1.Then)("I see link {string}", async function (text) {
|
|
42
44
|
const link = this.page.getByRole("link", { name: text });
|
|
43
45
|
if (!(await link.isVisible())) {
|
|
44
46
|
throw new Error(`Link "${text}" not visible`);
|
|
45
47
|
}
|
|
46
48
|
});
|
|
47
|
-
Then("I do not see link {string}", async function (text) {
|
|
49
|
+
(0, cucumber_1.Then)("I do not see link {string}", async function (text) {
|
|
48
50
|
const link = this.page.getByRole("link", { name: text });
|
|
49
51
|
if ((await link.count()) > 0 && (await link.first().isVisible())) {
|
|
50
52
|
throw new Error(`Link "${text}" is visible but should not be`);
|