playwright-cucumber-ts-steps 1.3.2 → 1.3.3
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 +358 -671
- package/dist/backend/actions/click.d.ts +29 -29
- package/dist/backend/actions/click.js +29 -29
- package/dist/backend/actions/form.d.ts +2 -2
- package/dist/backend/actions/form.js +2 -2
- package/dist/backend/actions/formTable.d.ts +1 -1
- package/dist/backend/actions/formTable.js +1 -1
- package/dist/backend/actions/frames.d.ts +3 -3
- package/dist/backend/actions/frames.js +3 -3
- package/dist/backend/actions/inputs.d.ts +14 -14
- package/dist/backend/actions/inputs.js +14 -14
- package/dist/backend/actions/interactions.d.ts +7 -7
- package/dist/backend/actions/interactions.js +7 -7
- package/dist/backend/actions/keyboard.d.ts +6 -6
- package/dist/backend/actions/keyboard.js +6 -6
- package/dist/backend/actions/misc.d.ts +15 -15
- package/dist/backend/actions/misc.js +15 -15
- package/dist/backend/actions/mobile.d.ts +7 -7
- package/dist/backend/actions/mobile.js +7 -7
- package/dist/backend/actions/mouse.d.ts +9 -9
- package/dist/backend/actions/mouse.js +9 -9
- package/dist/backend/actions/navigation.d.ts +5 -5
- package/dist/backend/actions/navigation.js +5 -5
- package/dist/backend/actions/visual.d.ts +6 -6
- package/dist/backend/actions/visual.js +6 -6
- package/dist/backend/actions/waits.d.ts +6 -6
- package/dist/backend/actions/waits.js +6 -6
- package/dist/backend/api/assertions.d.ts +3 -3
- package/dist/backend/api/assertions.js +3 -3
- package/dist/backend/api/mock.d.ts +3 -3
- package/dist/backend/api/mock.js +3 -3
- package/dist/backend/api/network.d.ts +6 -6
- package/dist/backend/api/network.js +6 -6
- package/dist/backend/api/requests.d.ts +4 -4
- package/dist/backend/api/requests.js +4 -4
- package/dist/backend/assertions/document.d.ts +10 -10
- package/dist/backend/assertions/document.js +10 -10
- package/dist/backend/assertions/elements.d.ts +28 -28
- package/dist/backend/assertions/elements.js +28 -28
- package/dist/backend/assertions/expectVisible.d.ts +1 -1
- package/dist/backend/assertions/expectVisible.js +1 -1
- package/dist/backend/assertions/forms.d.ts +7 -7
- package/dist/backend/assertions/forms.js +7 -7
- package/dist/backend/assertions/pageState.d.ts +4 -4
- package/dist/backend/assertions/pageState.js +4 -4
- package/dist/backend/assertions/storage.d.ts +11 -11
- package/dist/backend/assertions/storage.js +11 -11
- package/dist/backend/assertions/text.d.ts +17 -17
- package/dist/backend/assertions/text.js +17 -17
- package/dist/backend/assertions/visibility.d.ts +15 -15
- package/dist/backend/assertions/visibility.js +15 -15
- package/dist/backend/auth/index.d.ts +2 -2
- package/dist/backend/auth/index.js +2 -2
- package/dist/backend/db/steps.d.ts +9 -9
- package/dist/backend/db/steps.js +9 -9
- package/dist/backend/elements/alerts.d.ts +3 -3
- package/dist/backend/elements/alerts.js +3 -3
- package/dist/backend/elements/find.d.ts +15 -15
- package/dist/backend/elements/find.js +15 -15
- package/dist/backend/elements/forms.d.ts +4 -4
- package/dist/backend/elements/forms.js +4 -4
- package/dist/backend/elements/frames.d.ts +3 -3
- package/dist/backend/elements/frames.js +3 -3
- package/dist/backend/utils/fixtures.d.ts +22 -0
- package/dist/backend/utils/fixtures.d.ts.map +1 -1
- package/dist/backend/utils/fixtures.js +76 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Scrolls a specific element into the visible viewport.
|
|
3
3
|
* Supports fixtures for reusable selectors.
|
|
4
|
-
* @example When I scroll "footer.footerSection" into view
|
|
4
|
+
* @example When I pw scroll "footer.footerSection" into view
|
|
5
5
|
*/
|
|
6
6
|
export declare function scrollIntoView(page: any, selectorKey: string): Promise<void>;
|
|
7
7
|
/**
|
|
8
8
|
* Scrolls the internal content of a specific element (overflow container) to X, Y coordinates.
|
|
9
9
|
* Supports fixtures for reusable selectors.
|
|
10
|
-
* @example When I scroll "chat.chatBox" to position x:0 y:500
|
|
10
|
+
* @example When I pw scroll "chat.chatBox" to position x:0 y:500
|
|
11
11
|
*/
|
|
12
12
|
export declare function scrollElementToPosition(page: any, selectorKey: string, x: number, y: number): Promise<void>;
|
|
13
13
|
/**
|
|
14
14
|
* Scrolls the entire main browser window to specific X, Y coordinates immediately.
|
|
15
|
-
* @example When I scroll to coordinates x:0 y:0
|
|
15
|
+
* @example When I pw scroll to coordinates x:0 y:0
|
|
16
16
|
*/
|
|
17
17
|
export declare function scrollWindowToCoordinates(page: any, x: number, y: number): Promise<void>;
|
|
18
18
|
/**
|
|
19
19
|
* Scrolls the entire main browser window smoothly to specific coordinates.
|
|
20
|
-
* @example When I scroll mouse window to position top:0 left:0
|
|
20
|
+
* @example When I pw scroll mouse window to position top:0 left:0
|
|
21
21
|
*/
|
|
22
22
|
export declare function scrollWindowSmoothly(page: any, top: number, left: number): Promise<void>;
|
|
23
23
|
/**
|
|
24
24
|
* Scrolls the window to a general direction edge (top, bottom, left, right).
|
|
25
25
|
* Includes a short wait for smooth scrolling animation to complete.
|
|
26
|
-
* @example When I scroll to "bottom"
|
|
26
|
+
* @example When I pw scroll to "bottom"
|
|
27
27
|
*/
|
|
28
28
|
export declare function scrollToDirection(page: any, direction: string): Promise<void>;
|
|
29
29
|
/**
|
|
30
30
|
* Simulates a mouse hover over an element.
|
|
31
31
|
* Sets the hovered element as the "Active Element" for subsequent steps.
|
|
32
32
|
* Supports fixtures for reusable selectors.
|
|
33
|
-
* @example When I hover over the element "dropdown.toggleButton"
|
|
33
|
+
* @example When I pw hover over the element "dropdown.toggleButton"
|
|
34
34
|
*/
|
|
35
35
|
export declare function hoverElement(page: any, selectorKey: string): Promise<void>;
|
|
36
36
|
/**
|
|
37
37
|
* Moves the mouse cursor to specific absolute screen coordinates.
|
|
38
38
|
* Useful for canvas interactions or testing mouse tracking.
|
|
39
|
-
* @example When I move mouse to coordinates 100, 200
|
|
39
|
+
* @example When I pw move mouse to coordinates 100, 200
|
|
40
40
|
*/
|
|
41
41
|
export declare function moveMouseToCoordinates(page: any, x: number, y: number): Promise<void>;
|
|
42
42
|
/**
|
|
43
43
|
* Hovers over the Nth element containing the specified text.
|
|
44
|
-
* @example When I hover on 1st element "Profile"
|
|
44
|
+
* @example When I pw hover on 1st element "Profile"
|
|
45
45
|
*/
|
|
46
46
|
export declare function hoverNthElementByText(page: any, indexStr: string, text: string, table?: any): Promise<void>;
|
|
47
47
|
/**
|
|
48
48
|
* Hovers over the Nth element matching a CSS or XPath selector.
|
|
49
49
|
* Supports fixtures for reusable selectors.
|
|
50
|
-
* @example When I hover on 1st selector "user.avatar"
|
|
50
|
+
* @example When I pw hover on 1st selector "user.avatar"
|
|
51
51
|
*/
|
|
52
52
|
export declare function hoverNthElementBySelector(page: any, indexStr: string, selectorKey: string, table?: any): Promise<void>;
|
|
53
53
|
//# sourceMappingURL=mouse.d.ts.map
|
|
@@ -19,7 +19,7 @@ const fixtures_1 = require("../utils/fixtures");
|
|
|
19
19
|
/**
|
|
20
20
|
* Scrolls a specific element into the visible viewport.
|
|
21
21
|
* Supports fixtures for reusable selectors.
|
|
22
|
-
* @example When I scroll "footer.footerSection" into view
|
|
22
|
+
* @example When I pw scroll "footer.footerSection" into view
|
|
23
23
|
*/
|
|
24
24
|
async function scrollIntoView(page, selectorKey) {
|
|
25
25
|
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
@@ -31,7 +31,7 @@ async function scrollIntoView(page, selectorKey) {
|
|
|
31
31
|
/**
|
|
32
32
|
* Scrolls the internal content of a specific element (overflow container) to X, Y coordinates.
|
|
33
33
|
* Supports fixtures for reusable selectors.
|
|
34
|
-
* @example When I scroll "chat.chatBox" to position x:0 y:500
|
|
34
|
+
* @example When I pw scroll "chat.chatBox" to position x:0 y:500
|
|
35
35
|
*/
|
|
36
36
|
async function scrollElementToPosition(page, selectorKey, x, y) {
|
|
37
37
|
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
@@ -44,7 +44,7 @@ async function scrollElementToPosition(page, selectorKey, x, y) {
|
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Scrolls the entire main browser window to specific X, Y coordinates immediately.
|
|
47
|
-
* @example When I scroll to coordinates x:0 y:0
|
|
47
|
+
* @example When I pw scroll to coordinates x:0 y:0
|
|
48
48
|
*/
|
|
49
49
|
async function scrollWindowToCoordinates(page, x, y) {
|
|
50
50
|
await page.evaluate((coords) => {
|
|
@@ -54,7 +54,7 @@ async function scrollWindowToCoordinates(page, x, y) {
|
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Scrolls the entire main browser window smoothly to specific coordinates.
|
|
57
|
-
* @example When I scroll mouse window to position top:0 left:0
|
|
57
|
+
* @example When I pw scroll mouse window to position top:0 left:0
|
|
58
58
|
*/
|
|
59
59
|
async function scrollWindowSmoothly(page, top, left) {
|
|
60
60
|
await page.evaluate((coords) => {
|
|
@@ -69,7 +69,7 @@ async function scrollWindowSmoothly(page, top, left) {
|
|
|
69
69
|
/**
|
|
70
70
|
* Scrolls the window to a general direction edge (top, bottom, left, right).
|
|
71
71
|
* Includes a short wait for smooth scrolling animation to complete.
|
|
72
|
-
* @example When I scroll to "bottom"
|
|
72
|
+
* @example When I pw scroll to "bottom"
|
|
73
73
|
*/
|
|
74
74
|
async function scrollToDirection(page, direction) {
|
|
75
75
|
const validDirections = ["top", "bottom", "left", "right"];
|
|
@@ -103,7 +103,7 @@ async function scrollToDirection(page, direction) {
|
|
|
103
103
|
* Simulates a mouse hover over an element.
|
|
104
104
|
* Sets the hovered element as the "Active Element" for subsequent steps.
|
|
105
105
|
* Supports fixtures for reusable selectors.
|
|
106
|
-
* @example When I hover over the element "dropdown.toggleButton"
|
|
106
|
+
* @example When I pw hover over the element "dropdown.toggleButton"
|
|
107
107
|
*/
|
|
108
108
|
async function hoverElement(page, selectorKey) {
|
|
109
109
|
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
@@ -116,7 +116,7 @@ async function hoverElement(page, selectorKey) {
|
|
|
116
116
|
/**
|
|
117
117
|
* Moves the mouse cursor to specific absolute screen coordinates.
|
|
118
118
|
* Useful for canvas interactions or testing mouse tracking.
|
|
119
|
-
* @example When I move mouse to coordinates 100, 200
|
|
119
|
+
* @example When I pw move mouse to coordinates 100, 200
|
|
120
120
|
*/
|
|
121
121
|
async function moveMouseToCoordinates(page, x, y) {
|
|
122
122
|
await page.mouse.move(x, y);
|
|
@@ -124,7 +124,7 @@ async function moveMouseToCoordinates(page, x, y) {
|
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* Hovers over the Nth element containing the specified text.
|
|
127
|
-
* @example When I hover on 1st element "Profile"
|
|
127
|
+
* @example When I pw hover on 1st element "Profile"
|
|
128
128
|
*/
|
|
129
129
|
async function hoverNthElementByText(page, indexStr, text, table) {
|
|
130
130
|
const index = parseInt(indexStr, 10);
|
|
@@ -138,7 +138,7 @@ async function hoverNthElementByText(page, indexStr, text, table) {
|
|
|
138
138
|
/**
|
|
139
139
|
* Hovers over the Nth element matching a CSS or XPath selector.
|
|
140
140
|
* Supports fixtures for reusable selectors.
|
|
141
|
-
* @example When I hover on 1st selector "user.avatar"
|
|
141
|
+
* @example When I pw hover on 1st selector "user.avatar"
|
|
142
142
|
*/
|
|
143
143
|
async function hoverNthElementBySelector(page, indexStr, selectorKey, table) {
|
|
144
144
|
const index = parseInt(indexStr, 10);
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Navigates the browser to a specific absolute URL.
|
|
3
3
|
* @example
|
|
4
|
-
* Given I visit "https://www.google.com"
|
|
4
|
+
* Given I pw visit "https://www.google.com"
|
|
5
5
|
* @param url - The full URL string (must include http/https).
|
|
6
6
|
*/
|
|
7
7
|
export declare function visitUrl(page: any, url: string): Promise<void>;
|
|
8
8
|
/**
|
|
9
9
|
* Reloads the current page (simulates hitting the Refresh button).
|
|
10
10
|
* @example
|
|
11
|
-
* When I reload the page
|
|
11
|
+
* When I pw reload the page
|
|
12
12
|
*/
|
|
13
13
|
export declare function reloadPage(page: any): Promise<void>;
|
|
14
14
|
/**
|
|
15
15
|
* Navigates back one step in the browser history.
|
|
16
16
|
* Simulates clicking the browser's "Back" button.
|
|
17
17
|
* @example
|
|
18
|
-
* When I go back
|
|
18
|
+
* When I pw go back
|
|
19
19
|
*/
|
|
20
20
|
export declare function goBack(page: any): Promise<void>;
|
|
21
21
|
/**
|
|
22
22
|
* Navigates forward one step in the browser history.
|
|
23
23
|
* Simulates clicking the browser's "Forward" button.
|
|
24
24
|
* @example
|
|
25
|
-
* When I go forward
|
|
25
|
+
* When I pw go forward
|
|
26
26
|
*/
|
|
27
27
|
export declare function goForward(page: any): Promise<void>;
|
|
28
28
|
/**
|
|
@@ -30,7 +30,7 @@ export declare function goForward(page: any): Promise<void>;
|
|
|
30
30
|
* If a `baseURL` is configured in your Playwright config, this is relative to it.
|
|
31
31
|
* Otherwise, it treats the string as a direct URL.
|
|
32
32
|
* @example
|
|
33
|
-
* When I navigate to "/dashboard/login"
|
|
33
|
+
* When I pw navigate to "/dashboard/login"
|
|
34
34
|
* @param path - The relative path or URL to navigate to.
|
|
35
35
|
*/
|
|
36
36
|
export declare function navigateToPath(page: any, path: string): Promise<void>;
|
|
@@ -13,7 +13,7 @@ const registry_1 = require("../../core/registry");
|
|
|
13
13
|
/**
|
|
14
14
|
* Navigates the browser to a specific absolute URL.
|
|
15
15
|
* @example
|
|
16
|
-
* Given I visit "https://www.google.com"
|
|
16
|
+
* Given I pw visit "https://www.google.com"
|
|
17
17
|
* @param url - The full URL string (must include http/https).
|
|
18
18
|
*/
|
|
19
19
|
async function visitUrl(page, url) {
|
|
@@ -23,7 +23,7 @@ async function visitUrl(page, url) {
|
|
|
23
23
|
/**
|
|
24
24
|
* Reloads the current page (simulates hitting the Refresh button).
|
|
25
25
|
* @example
|
|
26
|
-
* When I reload the page
|
|
26
|
+
* When I pw reload the page
|
|
27
27
|
*/
|
|
28
28
|
async function reloadPage(page) {
|
|
29
29
|
await page.reload();
|
|
@@ -33,7 +33,7 @@ async function reloadPage(page) {
|
|
|
33
33
|
* Navigates back one step in the browser history.
|
|
34
34
|
* Simulates clicking the browser's "Back" button.
|
|
35
35
|
* @example
|
|
36
|
-
* When I go back
|
|
36
|
+
* When I pw go back
|
|
37
37
|
*/
|
|
38
38
|
async function goBack(page) {
|
|
39
39
|
await page.goBack();
|
|
@@ -43,7 +43,7 @@ async function goBack(page) {
|
|
|
43
43
|
* Navigates forward one step in the browser history.
|
|
44
44
|
* Simulates clicking the browser's "Forward" button.
|
|
45
45
|
* @example
|
|
46
|
-
* When I go forward
|
|
46
|
+
* When I pw go forward
|
|
47
47
|
*/
|
|
48
48
|
async function goForward(page) {
|
|
49
49
|
await page.goForward();
|
|
@@ -54,7 +54,7 @@ async function goForward(page) {
|
|
|
54
54
|
* If a `baseURL` is configured in your Playwright config, this is relative to it.
|
|
55
55
|
* Otherwise, it treats the string as a direct URL.
|
|
56
56
|
* @example
|
|
57
|
-
* When I navigate to "/dashboard/login"
|
|
57
|
+
* When I pw navigate to "/dashboard/login"
|
|
58
58
|
* @param path - The relative path or URL to navigate to.
|
|
59
59
|
*/
|
|
60
60
|
async function navigateToPath(page, path) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Takes a screenshot of the entire page.
|
|
3
3
|
* @param page - The Playwright page object
|
|
4
4
|
* @param filename - The filename to save the screenshot as
|
|
5
|
-
* @example When I take a screenshot of the page "dashboard-view.png"
|
|
5
|
+
* @example When I pw take a screenshot of the page "dashboard-view.png"
|
|
6
6
|
*/
|
|
7
7
|
export declare function takePageScreenshot(page: any, filename: string): Promise<void>;
|
|
8
8
|
/**
|
|
@@ -10,14 +10,14 @@ export declare function takePageScreenshot(page: any, filename: string): Promise
|
|
|
10
10
|
* @param page - The Playwright page object
|
|
11
11
|
* @param selectorKey - The selector key (can be a fixture key or raw CSS selector)
|
|
12
12
|
* @param filename - The filename to save the screenshot as
|
|
13
|
-
* @example When I take a screenshot of element "header.navbar" as "navbar.png"
|
|
13
|
+
* @example When I pw take a screenshot of element "header.navbar" as "navbar.png"
|
|
14
14
|
*/
|
|
15
15
|
export declare function takeElementScreenshot(page: any, selectorKey: string, filename: string): Promise<void>;
|
|
16
16
|
/**
|
|
17
17
|
* Takes a screenshot of the viewport area.
|
|
18
18
|
* @param page - The Playwright page object
|
|
19
19
|
* @param filename - The filename to save the screenshot as
|
|
20
|
-
* @example When I take a viewport screenshot "login-area.png"
|
|
20
|
+
* @example When I pw take a viewport screenshot "login-area.png"
|
|
21
21
|
*/
|
|
22
22
|
export declare function takeViewportScreenshot(page: any, filename: string): Promise<void>;
|
|
23
23
|
/**
|
|
@@ -25,7 +25,7 @@ export declare function takeViewportScreenshot(page: any, filename: string): Pro
|
|
|
25
25
|
* @param page - The Playwright page object
|
|
26
26
|
* @param currentFilename - The filename of the current page screenshot
|
|
27
27
|
* @param referenceFilename - The filename of the reference screenshot to compare with
|
|
28
|
-
* @example Then I expect page "current-view.png" to closely match "reference-view.png"
|
|
28
|
+
* @example Then I pw expect page "current-view.png" to closely match "reference-view.png"
|
|
29
29
|
*/
|
|
30
30
|
export declare function expectPageToCloselyMatch(page: any, currentFilename: string, referenceFilename: string): Promise<void>;
|
|
31
31
|
/**
|
|
@@ -34,14 +34,14 @@ export declare function expectPageToCloselyMatch(page: any, currentFilename: str
|
|
|
34
34
|
* @param selectorKey - The selector key (can be a fixture key or raw CSS selector)
|
|
35
35
|
* @param currentFilename - The filename of the current element screenshot
|
|
36
36
|
* @param referenceFilename - The filename of the reference screenshot to compare with
|
|
37
|
-
* @example Then I expect element "div.content" screenshot "content-current.png" to closely match "content-reference.png"
|
|
37
|
+
* @example Then I pw expect element "div.content" screenshot "content-current.png" to closely match "content-reference.png"
|
|
38
38
|
*/
|
|
39
39
|
export declare function expectElementToCloselyMatch(page: any, selectorKey: string, currentFilename: string, referenceFilename: string): Promise<void>;
|
|
40
40
|
/**
|
|
41
41
|
* Takes a screenshot and attaches it to the test report.
|
|
42
42
|
* @param page - The Playwright page object
|
|
43
43
|
* @param name - The name to identify the screenshot in the report
|
|
44
|
-
* @example When I capture screenshot "error-state" for the report
|
|
44
|
+
* @example When I pw capture screenshot "error-state" for the report
|
|
45
45
|
*/
|
|
46
46
|
export declare function captureScreenshotForReport(page: any, name: string): Promise<void>;
|
|
47
47
|
//# sourceMappingURL=visual.d.ts.map
|
|
@@ -17,7 +17,7 @@ const fixtures_1 = require("../utils/fixtures");
|
|
|
17
17
|
* Takes a screenshot of the entire page.
|
|
18
18
|
* @param page - The Playwright page object
|
|
19
19
|
* @param filename - The filename to save the screenshot as
|
|
20
|
-
* @example When I take a screenshot of the page "dashboard-view.png"
|
|
20
|
+
* @example When I pw take a screenshot of the page "dashboard-view.png"
|
|
21
21
|
*/
|
|
22
22
|
async function takePageScreenshot(page, filename) {
|
|
23
23
|
await page.screenshot({ path: `screenshots/${filename}`, fullPage: true });
|
|
@@ -28,7 +28,7 @@ async function takePageScreenshot(page, filename) {
|
|
|
28
28
|
* @param page - The Playwright page object
|
|
29
29
|
* @param selectorKey - The selector key (can be a fixture key or raw CSS selector)
|
|
30
30
|
* @param filename - The filename to save the screenshot as
|
|
31
|
-
* @example When I take a screenshot of element "header.navbar" as "navbar.png"
|
|
31
|
+
* @example When I pw take a screenshot of element "header.navbar" as "navbar.png"
|
|
32
32
|
*/
|
|
33
33
|
async function takeElementScreenshot(page, selectorKey, filename) {
|
|
34
34
|
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
@@ -41,7 +41,7 @@ async function takeElementScreenshot(page, selectorKey, filename) {
|
|
|
41
41
|
* Takes a screenshot of the viewport area.
|
|
42
42
|
* @param page - The Playwright page object
|
|
43
43
|
* @param filename - The filename to save the screenshot as
|
|
44
|
-
* @example When I take a viewport screenshot "login-area.png"
|
|
44
|
+
* @example When I pw take a viewport screenshot "login-area.png"
|
|
45
45
|
*/
|
|
46
46
|
async function takeViewportScreenshot(page, filename) {
|
|
47
47
|
await page.screenshot({ path: `screenshots/${filename}` });
|
|
@@ -52,7 +52,7 @@ async function takeViewportScreenshot(page, filename) {
|
|
|
52
52
|
* @param page - The Playwright page object
|
|
53
53
|
* @param currentFilename - The filename of the current page screenshot
|
|
54
54
|
* @param referenceFilename - The filename of the reference screenshot to compare with
|
|
55
|
-
* @example Then I expect page "current-view.png" to closely match "reference-view.png"
|
|
55
|
+
* @example Then I pw expect page "current-view.png" to closely match "reference-view.png"
|
|
56
56
|
*/
|
|
57
57
|
async function expectPageToCloselyMatch(page, currentFilename, referenceFilename) {
|
|
58
58
|
// Playwright's screenshot comparison is already pixel-perfect by default
|
|
@@ -66,7 +66,7 @@ async function expectPageToCloselyMatch(page, currentFilename, referenceFilename
|
|
|
66
66
|
* @param selectorKey - The selector key (can be a fixture key or raw CSS selector)
|
|
67
67
|
* @param currentFilename - The filename of the current element screenshot
|
|
68
68
|
* @param referenceFilename - The filename of the reference screenshot to compare with
|
|
69
|
-
* @example Then I expect element "div.content" screenshot "content-current.png" to closely match "content-reference.png"
|
|
69
|
+
* @example Then I pw expect element "div.content" screenshot "content-current.png" to closely match "content-reference.png"
|
|
70
70
|
*/
|
|
71
71
|
async function expectElementToCloselyMatch(page, selectorKey, currentFilename, referenceFilename) {
|
|
72
72
|
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
@@ -79,7 +79,7 @@ async function expectElementToCloselyMatch(page, selectorKey, currentFilename, r
|
|
|
79
79
|
* Takes a screenshot and attaches it to the test report.
|
|
80
80
|
* @param page - The Playwright page object
|
|
81
81
|
* @param name - The name to identify the screenshot in the report
|
|
82
|
-
* @example When I capture screenshot "error-state" for the report
|
|
82
|
+
* @example When I pw capture screenshot "error-state" for the report
|
|
83
83
|
*/
|
|
84
84
|
async function captureScreenshotForReport(page, name) {
|
|
85
85
|
await page.screenshot();
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Waits for the network to reach an "idle" state.
|
|
3
3
|
* In Playwright terms, this means there are no new network connections for at least 500ms.
|
|
4
|
-
* @example When I wait for network idle
|
|
4
|
+
* @example When I pw wait for network idle
|
|
5
5
|
*/
|
|
6
6
|
export declare function waitForNetworkIdle(page: any): Promise<void>;
|
|
7
7
|
/**
|
|
8
8
|
* Waits for the page to reach a specific load lifecycle event.
|
|
9
|
-
* @example When I wait for load state "domcontentloaded"
|
|
9
|
+
* @example When I pw wait for load state "domcontentloaded"
|
|
10
10
|
*/
|
|
11
11
|
export declare function waitForLoadState(page: any, state: string): Promise<void>;
|
|
12
12
|
/**
|
|
13
13
|
* Explicitly waits for the currently stored (active) element to become visible.
|
|
14
14
|
* Useful for ensuring animations complete or modals appear before proceeding.
|
|
15
|
-
* @example When I wait for element to be visible
|
|
15
|
+
* @example When I pw wait for element to be visible
|
|
16
16
|
*/
|
|
17
17
|
export declare function waitForElementVisible(page: any): Promise<void>;
|
|
18
18
|
/**
|
|
19
19
|
* Explicitly waits for a specific element to become visible.
|
|
20
20
|
* Useful for ensuring animations complete or modals appear before proceeding.
|
|
21
|
-
* @example When I wait for "#modal" to be visible
|
|
21
|
+
* @example When I pw wait for "#modal" to be visible
|
|
22
22
|
*/
|
|
23
23
|
export declare function waitForElementVisibleBySelector(page: any, selectorKey: string): Promise<void>;
|
|
24
24
|
/**
|
|
25
25
|
* Explicitly waits for the currently stored (active) element to become hidden or detached from the DOM.
|
|
26
26
|
* Useful for verifying that loading spinners have disappeared.
|
|
27
|
-
* @example When I wait for element to be hidden
|
|
27
|
+
* @example When I pw wait for element to be hidden
|
|
28
28
|
*/
|
|
29
29
|
export declare function waitForElementHidden(page: any): Promise<void>;
|
|
30
30
|
/**
|
|
31
31
|
* Waits until the page URL contains the specified substring (Regex match).
|
|
32
32
|
* Supports fixtures for reusable URL parts.
|
|
33
|
-
* @example When I wait for URL to contain "dashboard"
|
|
33
|
+
* @example When I pw wait for URL to contain "dashboard"
|
|
34
34
|
*/
|
|
35
35
|
export declare function waitForUrlContain(page: any, urlPartKey: string): Promise<void>;
|
|
36
36
|
//# sourceMappingURL=waits.d.ts.map
|
|
@@ -15,7 +15,7 @@ const fixtures_1 = require("../utils/fixtures");
|
|
|
15
15
|
/**
|
|
16
16
|
* Waits for the network to reach an "idle" state.
|
|
17
17
|
* In Playwright terms, this means there are no new network connections for at least 500ms.
|
|
18
|
-
* @example When I wait for network idle
|
|
18
|
+
* @example When I pw wait for network idle
|
|
19
19
|
*/
|
|
20
20
|
async function waitForNetworkIdle(page) {
|
|
21
21
|
await page.waitForLoadState("networkidle");
|
|
@@ -23,7 +23,7 @@ async function waitForNetworkIdle(page) {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Waits for the page to reach a specific load lifecycle event.
|
|
26
|
-
* @example When I wait for load state "domcontentloaded"
|
|
26
|
+
* @example When I pw wait for load state "domcontentloaded"
|
|
27
27
|
*/
|
|
28
28
|
async function waitForLoadState(page, state) {
|
|
29
29
|
const validStates = ["load", "domcontentloaded", "networkidle"];
|
|
@@ -36,7 +36,7 @@ async function waitForLoadState(page, state) {
|
|
|
36
36
|
/**
|
|
37
37
|
* Explicitly waits for the currently stored (active) element to become visible.
|
|
38
38
|
* Useful for ensuring animations complete or modals appear before proceeding.
|
|
39
|
-
* @example When I wait for element to be visible
|
|
39
|
+
* @example When I pw wait for element to be visible
|
|
40
40
|
*/
|
|
41
41
|
async function waitForElementVisible(page) {
|
|
42
42
|
const element = (0, state_1.getActiveElement)(page);
|
|
@@ -46,7 +46,7 @@ async function waitForElementVisible(page) {
|
|
|
46
46
|
/**
|
|
47
47
|
* Explicitly waits for a specific element to become visible.
|
|
48
48
|
* Useful for ensuring animations complete or modals appear before proceeding.
|
|
49
|
-
* @example When I wait for "#modal" to be visible
|
|
49
|
+
* @example When I pw wait for "#modal" to be visible
|
|
50
50
|
*/
|
|
51
51
|
async function waitForElementVisibleBySelector(page, selectorKey) {
|
|
52
52
|
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
@@ -57,7 +57,7 @@ async function waitForElementVisibleBySelector(page, selectorKey) {
|
|
|
57
57
|
/**
|
|
58
58
|
* Explicitly waits for the currently stored (active) element to become hidden or detached from the DOM.
|
|
59
59
|
* Useful for verifying that loading spinners have disappeared.
|
|
60
|
-
* @example When I wait for element to be hidden
|
|
60
|
+
* @example When I pw wait for element to be hidden
|
|
61
61
|
*/
|
|
62
62
|
async function waitForElementHidden(page) {
|
|
63
63
|
const element = (0, state_1.getActiveElement)(page);
|
|
@@ -67,7 +67,7 @@ async function waitForElementHidden(page) {
|
|
|
67
67
|
/**
|
|
68
68
|
* Waits until the page URL contains the specified substring (Regex match).
|
|
69
69
|
* Supports fixtures for reusable URL parts.
|
|
70
|
-
* @example When I wait for URL to contain "dashboard"
|
|
70
|
+
* @example When I pw wait for URL to contain "dashboard"
|
|
71
71
|
*/
|
|
72
72
|
async function waitForUrlContain(page, urlPartKey) {
|
|
73
73
|
const urls = (0, fixtures_1.loadFixture)("urls.json");
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Asserts that the HTTP status code of the last API response matches the expected integer.
|
|
3
|
-
* @example Then I expect the response status to be 200
|
|
3
|
+
* @example Then I pw expect the response status to be 200
|
|
4
4
|
*/
|
|
5
5
|
export declare function expectResponseStatus(page: any, statusCode: number): Promise<void>;
|
|
6
6
|
/**
|
|
7
7
|
* Asserts that the body text of the last API response contains a specific substring.
|
|
8
8
|
* Supports fixtures for reusable substrings.
|
|
9
|
-
* @example Then I expect the response body to contain "success"
|
|
9
|
+
* @example Then I pw expect the response body to contain "success"
|
|
10
10
|
*/
|
|
11
11
|
export declare function expectResponseBodyContain(page: any, textKey: string): Promise<void>;
|
|
12
12
|
/**
|
|
13
13
|
* Asserts that a specific property in the JSON response matches a string value.
|
|
14
14
|
* Supports dot notation for nested properties and fixtures for reusable keys/values.
|
|
15
|
-
* @example Then I expect the response property "user.id" to be "12345"
|
|
15
|
+
* @example Then I pw expect the response property "user.id" to be "12345"
|
|
16
16
|
*/
|
|
17
17
|
export declare function expectResponseProperty(page: any, jsonPathKey: string, valueKey: string): Promise<void>;
|
|
18
18
|
//# sourceMappingURL=assertions.d.ts.map
|
|
@@ -13,7 +13,7 @@ const fixtures_1 = require("../utils/fixtures");
|
|
|
13
13
|
// ==================================================
|
|
14
14
|
/**
|
|
15
15
|
* Asserts that the HTTP status code of the last API response matches the expected integer.
|
|
16
|
-
* @example Then I expect the response status to be 200
|
|
16
|
+
* @example Then I pw expect the response status to be 200
|
|
17
17
|
*/
|
|
18
18
|
async function expectResponseStatus(page, statusCode) {
|
|
19
19
|
const response = state_1.apiState.getResponse();
|
|
@@ -25,7 +25,7 @@ async function expectResponseStatus(page, statusCode) {
|
|
|
25
25
|
/**
|
|
26
26
|
* Asserts that the body text of the last API response contains a specific substring.
|
|
27
27
|
* Supports fixtures for reusable substrings.
|
|
28
|
-
* @example Then I expect the response body to contain "success"
|
|
28
|
+
* @example Then I pw expect the response body to contain "success"
|
|
29
29
|
*/
|
|
30
30
|
async function expectResponseBodyContain(page, textKey) {
|
|
31
31
|
const response = state_1.apiState.getResponse();
|
|
@@ -40,7 +40,7 @@ async function expectResponseBodyContain(page, textKey) {
|
|
|
40
40
|
/**
|
|
41
41
|
* Asserts that a specific property in the JSON response matches a string value.
|
|
42
42
|
* Supports dot notation for nested properties and fixtures for reusable keys/values.
|
|
43
|
-
* @example Then I expect the response property "user.id" to be "12345"
|
|
43
|
+
* @example Then I pw expect the response property "user.id" to be "12345"
|
|
44
44
|
*/
|
|
45
45
|
async function expectResponseProperty(page, jsonPathKey, valueKey) {
|
|
46
46
|
const response = state_1.apiState.getResponse();
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mocks a specific API endpoint with a hardcoded inline JSON response body.
|
|
3
3
|
* Supports fixtures for reusable API endpoints.
|
|
4
|
-
* @example Given I mock the API endpoint "/api/users" with body '{"id": 1, "name": "Fake"}'
|
|
4
|
+
* @example Given I pw mock the API endpoint "/api/users" with body '{"id": 1, "name": "Fake"}'
|
|
5
5
|
*/
|
|
6
6
|
export declare function mockApiWithInlineJson(page: any, urlPatternKey: string, jsonBody: string): Promise<void>;
|
|
7
7
|
/**
|
|
8
8
|
* Mocks an API endpoint using the contents of a local JSON file.
|
|
9
9
|
* Supports fixtures for reusable API endpoints and mock files.
|
|
10
|
-
* @example Given I mock the API endpoint "/api/users" with response from "mocks/users.json"
|
|
10
|
+
* @example Given I pw mock the API endpoint "/api/users" with response from "mocks/users.json"
|
|
11
11
|
*/
|
|
12
12
|
export declare function mockApiWithFile(page: any, urlPatternKey: string, filePathKey: string): Promise<void>;
|
|
13
13
|
/**
|
|
14
14
|
* Mocks an API endpoint to return a specific HTTP status code only.
|
|
15
15
|
* Useful for simulating server errors like 500 or 404.
|
|
16
16
|
* Supports fixtures for reusable API endpoints.
|
|
17
|
-
* @example Given I mock the API endpoint "/api/broken" with status 500
|
|
17
|
+
* @example Given I pw mock the API endpoint "/api/broken" with status 500
|
|
18
18
|
*/
|
|
19
19
|
export declare function mockApiStatus(page: any, urlPatternKey: string, statusCode: number): Promise<void>;
|
|
20
20
|
//# sourceMappingURL=mock.d.ts.map
|
package/dist/backend/api/mock.js
CHANGED
|
@@ -46,7 +46,7 @@ const fixtures_1 = require("./../utils/fixtures");
|
|
|
46
46
|
/**
|
|
47
47
|
* Mocks a specific API endpoint with a hardcoded inline JSON response body.
|
|
48
48
|
* Supports fixtures for reusable API endpoints.
|
|
49
|
-
* @example Given I mock the API endpoint "/api/users" with body '{"id": 1, "name": "Fake"}'
|
|
49
|
+
* @example Given I pw mock the API endpoint "/api/users" with body '{"id": 1, "name": "Fake"}'
|
|
50
50
|
*/
|
|
51
51
|
async function mockApiWithInlineJson(page, urlPatternKey, jsonBody) {
|
|
52
52
|
const endpoints = (0, fixtures_1.loadFixture)("endpoints.json");
|
|
@@ -64,7 +64,7 @@ async function mockApiWithInlineJson(page, urlPatternKey, jsonBody) {
|
|
|
64
64
|
/**
|
|
65
65
|
* Mocks an API endpoint using the contents of a local JSON file.
|
|
66
66
|
* Supports fixtures for reusable API endpoints and mock files.
|
|
67
|
-
* @example Given I mock the API endpoint "/api/users" with response from "mocks/users.json"
|
|
67
|
+
* @example Given I pw mock the API endpoint "/api/users" with response from "mocks/users.json"
|
|
68
68
|
*/
|
|
69
69
|
async function mockApiWithFile(page, urlPatternKey, filePathKey) {
|
|
70
70
|
const endpoints = (0, fixtures_1.loadFixture)("endpoints.json");
|
|
@@ -89,7 +89,7 @@ async function mockApiWithFile(page, urlPatternKey, filePathKey) {
|
|
|
89
89
|
* Mocks an API endpoint to return a specific HTTP status code only.
|
|
90
90
|
* Useful for simulating server errors like 500 or 404.
|
|
91
91
|
* Supports fixtures for reusable API endpoints.
|
|
92
|
-
* @example Given I mock the API endpoint "/api/broken" with status 500
|
|
92
|
+
* @example Given I pw mock the API endpoint "/api/broken" with status 500
|
|
93
93
|
*/
|
|
94
94
|
async function mockApiStatus(page, urlPatternKey, statusCode) {
|
|
95
95
|
const endpoints = (0, fixtures_1.loadFixture)("endpoints.json");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Intercepts a network URL and returns a stubbed JSON response.
|
|
3
3
|
* Supports Gherkin DocStrings for the body content.
|
|
4
|
-
* @example When I intercept URL "/api/user" and stub body:
|
|
4
|
+
* @example When I pw intercept URL "/api/user" and stub body:
|
|
5
5
|
* """
|
|
6
6
|
* { "id": 101, "status": "active" }
|
|
7
7
|
* """
|
|
@@ -9,24 +9,24 @@
|
|
|
9
9
|
export declare function interceptStubJson(page: any, url: string, body: any): Promise<void>;
|
|
10
10
|
/**
|
|
11
11
|
* Intercepts a URL and stubs it with a raw string (non-JSON).
|
|
12
|
-
* @example When I intercept URL "/health" and stub body "OK"
|
|
12
|
+
* @example When I pw intercept URL "/health" and stub body "OK"
|
|
13
13
|
*/
|
|
14
14
|
export declare function interceptStubRaw(page: any, url: string, body: string): Promise<void>;
|
|
15
15
|
/**
|
|
16
16
|
* Intercepts a URL but allows it to continue (Network Spying).
|
|
17
17
|
* Useful for monitoring traffic without changing the response.
|
|
18
|
-
* @example When I intercept URL "/api/*"
|
|
18
|
+
* @example When I pw intercept URL "/api/*"
|
|
19
19
|
*/
|
|
20
20
|
export declare function interceptSpy(page: any, url: string): Promise<void>;
|
|
21
21
|
/**
|
|
22
22
|
* Makes a GET request and stores the response in the test state.
|
|
23
23
|
* Stores values in `lastResponse` and `lastStatusCode`.
|
|
24
|
-
* @example When I make request to "https://api.example.com/v1/users"
|
|
24
|
+
* @example When I pw make request to "https://api.example.com/v1/users"
|
|
25
25
|
*/
|
|
26
26
|
export declare function apiGetRequest(page: any, url: string): Promise<void>;
|
|
27
27
|
/**
|
|
28
28
|
* Makes a POST request with a JSON body provided via DocString.
|
|
29
|
-
* @example When I make a POST request to "/api/login" with JSON body:
|
|
29
|
+
* @example When I pw make a POST request to "/api/login" with JSON body:
|
|
30
30
|
* """
|
|
31
31
|
* { "username": "admin", "password": "password123" }
|
|
32
32
|
* """
|
|
@@ -35,7 +35,7 @@ export declare function apiPostRequest(page: any, url: string, docString: any):
|
|
|
35
35
|
/**
|
|
36
36
|
* Makes a generic HTTP request using the browser's `fetch` API.
|
|
37
37
|
* Supports a data table for headers and an optional body.
|
|
38
|
-
* @example When I make a "PUT" request to "/api/settings"
|
|
38
|
+
* @example When I pw make a "PUT" request to "/api/settings"
|
|
39
39
|
* | Authorization | Bearer my-token |
|
|
40
40
|
* | body | {"theme": "dark"} |
|
|
41
41
|
*/
|
|
@@ -36,7 +36,7 @@ function safeJsonParse(input, context) {
|
|
|
36
36
|
/**
|
|
37
37
|
* Intercepts a network URL and returns a stubbed JSON response.
|
|
38
38
|
* Supports Gherkin DocStrings for the body content.
|
|
39
|
-
* @example When I intercept URL "/api/user" and stub body:
|
|
39
|
+
* @example When I pw intercept URL "/api/user" and stub body:
|
|
40
40
|
* """
|
|
41
41
|
* { "id": 101, "status": "active" }
|
|
42
42
|
* """
|
|
@@ -54,7 +54,7 @@ async function interceptStubJson(page, url, body) {
|
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Intercepts a URL and stubs it with a raw string (non-JSON).
|
|
57
|
-
* @example When I intercept URL "/health" and stub body "OK"
|
|
57
|
+
* @example When I pw intercept URL "/health" and stub body "OK"
|
|
58
58
|
*/
|
|
59
59
|
async function interceptStubRaw(page, url, body) {
|
|
60
60
|
await page.route(url, (route) => {
|
|
@@ -69,7 +69,7 @@ async function interceptStubRaw(page, url, body) {
|
|
|
69
69
|
/**
|
|
70
70
|
* Intercepts a URL but allows it to continue (Network Spying).
|
|
71
71
|
* Useful for monitoring traffic without changing the response.
|
|
72
|
-
* @example When I intercept URL "/api/*"
|
|
72
|
+
* @example When I pw intercept URL "/api/*"
|
|
73
73
|
*/
|
|
74
74
|
async function interceptSpy(page, url) {
|
|
75
75
|
await page.route(url, async (route) => {
|
|
@@ -80,7 +80,7 @@ async function interceptSpy(page, url) {
|
|
|
80
80
|
/**
|
|
81
81
|
* Makes a GET request and stores the response in the test state.
|
|
82
82
|
* Stores values in `lastResponse` and `lastStatusCode`.
|
|
83
|
-
* @example When I make request to "https://api.example.com/v1/users"
|
|
83
|
+
* @example When I pw make request to "https://api.example.com/v1/users"
|
|
84
84
|
*/
|
|
85
85
|
async function apiGetRequest(page, url) {
|
|
86
86
|
console.log(`⚡ GET request to: ${url}`);
|
|
@@ -98,7 +98,7 @@ async function apiGetRequest(page, url) {
|
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* Makes a POST request with a JSON body provided via DocString.
|
|
101
|
-
* @example When I make a POST request to "/api/login" with JSON body:
|
|
101
|
+
* @example When I pw make a POST request to "/api/login" with JSON body:
|
|
102
102
|
* """
|
|
103
103
|
* { "username": "admin", "password": "password123" }
|
|
104
104
|
* """
|
|
@@ -121,7 +121,7 @@ async function apiPostRequest(page, url, docString) {
|
|
|
121
121
|
/**
|
|
122
122
|
* Makes a generic HTTP request using the browser's `fetch` API.
|
|
123
123
|
* Supports a data table for headers and an optional body.
|
|
124
|
-
* @example When I make a "PUT" request to "/api/settings"
|
|
124
|
+
* @example When I pw make a "PUT" request to "/api/settings"
|
|
125
125
|
* | Authorization | Bearer my-token |
|
|
126
126
|
* | body | {"theme": "dark"} |
|
|
127
127
|
*/
|