playwright-cucumber-ts-steps 0.1.7 → 1.0.1
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 +21 -11
- package/lib/actions/clickSteps.d.ts +251 -1
- package/lib/actions/clickSteps.js +297 -47
- package/lib/actions/cookieSteps.d.ts +18 -1
- package/lib/actions/cookieSteps.js +65 -0
- package/lib/actions/debugSteps.d.ts +14 -1
- package/lib/actions/debugSteps.js +18 -3
- package/lib/actions/elementFindSteps.d.ts +668 -1
- package/lib/actions/elementFindSteps.js +808 -94
- package/lib/actions/fillFormSteps.d.ts +69 -1
- package/lib/actions/fillFormSteps.js +178 -71
- package/lib/actions/index.d.ts +11 -0
- package/lib/actions/index.js +28 -0
- package/lib/actions/inputSteps.d.ts +218 -1
- package/lib/actions/inputSteps.js +303 -57
- package/lib/actions/interceptionSteps.d.ts +169 -1
- package/lib/actions/interceptionSteps.js +258 -38
- package/lib/actions/miscSteps.d.ts +645 -1
- package/lib/actions/miscSteps.js +898 -157
- package/lib/actions/mouseSteps.d.ts +143 -1
- package/lib/actions/mouseSteps.js +200 -32
- package/lib/actions/scrollSteps.d.ts +82 -1
- package/lib/actions/scrollSteps.js +116 -16
- package/lib/actions/storageSteps.d.ts +174 -1
- package/lib/actions/storageSteps.js +253 -33
- package/lib/assertions/buttonAndTextVisibilitySteps.d.ts +245 -1
- package/lib/assertions/buttonAndTextVisibilitySteps.js +342 -91
- package/lib/assertions/cookieSteps.d.ts +75 -1
- package/lib/assertions/cookieSteps.js +97 -29
- package/lib/assertions/elementSteps.d.ts +264 -1
- package/lib/assertions/elementSteps.js +376 -78
- package/lib/assertions/formInputSteps.d.ts +248 -1
- package/lib/assertions/formInputSteps.js +342 -79
- package/lib/assertions/index.d.ts +10 -0
- package/lib/assertions/index.js +27 -0
- package/lib/assertions/interceptionRequestsSteps.d.ts +353 -1
- package/lib/assertions/interceptionRequestsSteps.js +569 -177
- package/lib/assertions/locationSteps.d.ts +217 -1
- package/lib/assertions/locationSteps.js +287 -64
- package/lib/assertions/roleTestIdSteps.d.ts +159 -1
- package/lib/assertions/roleTestIdSteps.js +217 -22
- package/lib/assertions/semanticSteps.d.ts +176 -1
- package/lib/assertions/semanticSteps.js +245 -60
- package/lib/assertions/storageSteps.d.ts +149 -1
- package/lib/assertions/storageSteps.js +201 -65
- package/lib/assertions/visualSteps.d.ts +74 -1
- package/lib/assertions/visualSteps.js +178 -45
- package/lib/custom_setups/loginHooks.js +19 -2
- package/lib/helpers/world.d.ts +3 -0
- package/lib/helpers/world.js +11 -5
- package/lib/index.d.ts +3 -21
- package/lib/index.js +3 -23
- package/package.json +9 -2
- package/src/actions/clickSteps.ts +364 -142
- package/src/actions/cookieSteps.ts +66 -0
- package/src/actions/debugSteps.ts +17 -3
- package/src/actions/elementFindSteps.ts +822 -117
- package/src/actions/fillFormSteps.ts +234 -177
- package/src/actions/index.ts +12 -0
- package/src/actions/inputSteps.ts +318 -82
- package/src/actions/interceptionSteps.ts +295 -57
- package/src/actions/miscSteps.ts +984 -254
- package/src/actions/mouseSteps.ts +212 -55
- package/src/actions/scrollSteps.ts +114 -16
- package/src/actions/storageSteps.ts +267 -42
- package/src/assertions/buttonAndTextVisibilitySteps.ts +353 -95
- package/src/assertions/cookieSteps.ts +115 -36
- package/src/assertions/elementSteps.ts +414 -85
- package/src/assertions/formInputSteps.ts +375 -108
- package/src/assertions/index.ts +11 -0
- package/src/assertions/interceptionRequestsSteps.ts +619 -195
- package/src/assertions/locationSteps.ts +280 -64
- package/src/assertions/roleTestIdSteps.ts +244 -26
- package/src/assertions/semanticSteps.ts +257 -69
- package/src/assertions/storageSteps.ts +234 -73
- package/src/assertions/visualSteps.ts +245 -68
- package/src/custom_setups/loginHooks.ts +21 -2
- package/src/helpers/world.ts +30 -4
- package/src/index.ts +4 -25
package/lib/helpers/world.d.ts
CHANGED
|
@@ -12,10 +12,13 @@ export declare class CustomWorld extends World {
|
|
|
12
12
|
elements?: Locator;
|
|
13
13
|
element?: Locator;
|
|
14
14
|
frame?: FrameLocator;
|
|
15
|
+
currentLocator?: Locator;
|
|
15
16
|
data: Record<string, any>;
|
|
16
17
|
logs: string[];
|
|
17
18
|
testName?: string;
|
|
19
|
+
fakeTimersActive: boolean;
|
|
18
20
|
config: TestConfig;
|
|
21
|
+
constructor(options: import("@cucumber/cucumber").IWorldOptions);
|
|
19
22
|
init(testInfo?: ITestCaseHookParameter): Promise<void>;
|
|
20
23
|
/**
|
|
21
24
|
* Returns the current interaction scope: either the main page or active frame.
|
package/lib/helpers/world.js
CHANGED
|
@@ -42,8 +42,8 @@ dotenv.config();
|
|
|
42
42
|
const isHeadless = process.env.HEADLESS !== "false";
|
|
43
43
|
const slowMo = process.env.SLOWMO ? Number(process.env.SLOWMO) : 0;
|
|
44
44
|
class CustomWorld extends cucumber_1.World {
|
|
45
|
-
constructor() {
|
|
46
|
-
super(
|
|
45
|
+
constructor(options) {
|
|
46
|
+
super(options);
|
|
47
47
|
this.data = {};
|
|
48
48
|
this.logs = [];
|
|
49
49
|
this.config = {
|
|
@@ -55,17 +55,24 @@ class CustomWorld extends cucumber_1.World {
|
|
|
55
55
|
this.logs.push(message);
|
|
56
56
|
console.log(`[LOG] ${message}`);
|
|
57
57
|
};
|
|
58
|
+
this.fakeTimersActive = false;
|
|
58
59
|
}
|
|
59
60
|
async init(testInfo) {
|
|
60
|
-
const
|
|
61
|
+
const info = testInfo ?? this.parameters?.testInfo;
|
|
62
|
+
const isMobile = info?.pickle.tags.some((tag) => tag.name === "@mobile");
|
|
61
63
|
const device = isMobile ? test_1.devices["Pixel 5"] : undefined;
|
|
62
64
|
this.browser = await playwright_1.chromium.launch({ headless: isHeadless, slowMo });
|
|
63
65
|
this.context = await this.browser.newContext({
|
|
64
66
|
...(device || {}),
|
|
65
67
|
recordVideo: { dir: `${this.config.artifactDir}/videos` },
|
|
66
68
|
});
|
|
69
|
+
// Important: Initialize clock mocking *before* navigating or interacting with the page
|
|
70
|
+
// if you intend to use page.clock. This typically involves addInitScript.
|
|
71
|
+
// However, the context.clock API does not usually require an init script for its methods.
|
|
72
|
+
// If you explicitly loaded a mocking library, you'd do it here.
|
|
73
|
+
// For just context.clock methods, they should be available.
|
|
67
74
|
this.page = await this.context.newPage();
|
|
68
|
-
this.testName =
|
|
75
|
+
this.testName = info?.pickle.name;
|
|
69
76
|
this.log(`🧪 Initialized context${isMobile ? " (mobile)" : ""}`);
|
|
70
77
|
}
|
|
71
78
|
/**
|
|
@@ -85,7 +92,6 @@ class CustomWorld extends cucumber_1.World {
|
|
|
85
92
|
this.log("⬅️ Exited iframe, scope is now main page");
|
|
86
93
|
}
|
|
87
94
|
async cleanup(testInfo) {
|
|
88
|
-
testInfo?.result?.status === "FAILED";
|
|
89
95
|
try {
|
|
90
96
|
await this.page?.close();
|
|
91
97
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
export * from "./actions/clickSteps";
|
|
2
|
-
export * from "./actions/cookieSteps";
|
|
3
|
-
export * from "./actions/debugSteps";
|
|
4
|
-
export * from "./actions/elementFindSteps";
|
|
5
|
-
export * from "./actions/fillFormSteps";
|
|
6
|
-
export * from "./actions/inputSteps";
|
|
7
|
-
export * from "./actions/interceptionSteps";
|
|
8
|
-
export * from "./actions/miscSteps";
|
|
9
|
-
export * from "./actions/mouseSteps";
|
|
10
|
-
export * from "./actions/scrollSteps";
|
|
11
|
-
export * from "./actions/storageSteps";
|
|
12
|
-
export * from "./assertions/buttonAndTextVisibilitySteps";
|
|
13
|
-
export * from "./assertions/cookieSteps";
|
|
14
|
-
export * from "./assertions/elementSteps";
|
|
15
|
-
export * from "./assertions/formInputSteps";
|
|
16
|
-
export * from "./assertions/interceptionRequestsSteps";
|
|
17
|
-
export * from "./assertions/locationSteps";
|
|
18
|
-
export * from "./assertions/roleTestIdSteps";
|
|
19
|
-
export * from "./assertions/semanticSteps";
|
|
20
|
-
export * from "./assertions/storageSteps";
|
|
21
|
-
export * from "./assertions/visualSteps";
|
|
22
1
|
export * from "./iframes/frames";
|
|
23
2
|
export * from "./custom_setups/loginHooks";
|
|
24
3
|
export * from "./helpers/compareSnapshots";
|
|
@@ -26,3 +5,6 @@ export * from "./helpers/hooks";
|
|
|
26
5
|
export * from "./helpers/utils";
|
|
27
6
|
export * from "./helpers/world";
|
|
28
7
|
export type { CustomWorld } from "./helpers/world";
|
|
8
|
+
export * from "./actions";
|
|
9
|
+
export * from "./assertions";
|
|
10
|
+
export * from "./custom_setups/loginHooks";
|
package/lib/index.js
CHANGED
|
@@ -14,29 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
// Actions
|
|
18
|
-
__exportStar(require("./actions/clickSteps"), exports);
|
|
19
|
-
__exportStar(require("./actions/cookieSteps"), exports);
|
|
20
|
-
__exportStar(require("./actions/debugSteps"), exports);
|
|
21
|
-
__exportStar(require("./actions/elementFindSteps"), exports);
|
|
22
|
-
__exportStar(require("./actions/fillFormSteps"), exports);
|
|
23
|
-
__exportStar(require("./actions/inputSteps"), exports);
|
|
24
|
-
__exportStar(require("./actions/interceptionSteps"), exports);
|
|
25
|
-
__exportStar(require("./actions/miscSteps"), exports);
|
|
26
|
-
__exportStar(require("./actions/mouseSteps"), exports);
|
|
27
|
-
__exportStar(require("./actions/scrollSteps"), exports);
|
|
28
|
-
__exportStar(require("./actions/storageSteps"), exports);
|
|
29
|
-
// Assertions
|
|
30
|
-
__exportStar(require("./assertions/buttonAndTextVisibilitySteps"), exports);
|
|
31
|
-
__exportStar(require("./assertions/cookieSteps"), exports);
|
|
32
|
-
__exportStar(require("./assertions/elementSteps"), exports);
|
|
33
|
-
__exportStar(require("./assertions/formInputSteps"), exports);
|
|
34
|
-
__exportStar(require("./assertions/interceptionRequestsSteps"), exports);
|
|
35
|
-
__exportStar(require("./assertions/locationSteps"), exports);
|
|
36
|
-
__exportStar(require("./assertions/roleTestIdSteps"), exports);
|
|
37
|
-
__exportStar(require("./assertions/semanticSteps"), exports);
|
|
38
|
-
__exportStar(require("./assertions/storageSteps"), exports);
|
|
39
|
-
__exportStar(require("./assertions/visualSteps"), exports);
|
|
40
17
|
// Iframes
|
|
41
18
|
__exportStar(require("./iframes/frames"), exports);
|
|
42
19
|
// Setup (custom hooks, login, etc.)
|
|
@@ -46,3 +23,6 @@ __exportStar(require("./helpers/compareSnapshots"), exports);
|
|
|
46
23
|
__exportStar(require("./helpers/hooks"), exports);
|
|
47
24
|
__exportStar(require("./helpers/utils"), exports);
|
|
48
25
|
__exportStar(require("./helpers/world"), exports);
|
|
26
|
+
__exportStar(require("./actions"), exports);
|
|
27
|
+
__exportStar(require("./assertions"), exports);
|
|
28
|
+
__exportStar(require("./custom_setups/loginHooks"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright-cucumber-ts-steps",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A collection of reusable Playwright step definitions for Cucumber in TypeScript, designed to streamline end-to-end testing across web, API, and mobile applications.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsc",
|
|
29
|
-
"docs": "typedoc
|
|
29
|
+
"docs": "typedoc",
|
|
30
|
+
"docs:deploy": "gh-pages -d temp-docs",
|
|
30
31
|
"prepare": "husky",
|
|
31
32
|
"lint": "eslint . --ext .ts",
|
|
32
33
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
@@ -79,6 +80,10 @@
|
|
|
79
80
|
"@cucumber/cucumber": "*",
|
|
80
81
|
"@playwright/test": "*"
|
|
81
82
|
},
|
|
83
|
+
"files": [
|
|
84
|
+
"lib/",
|
|
85
|
+
"src/"
|
|
86
|
+
],
|
|
82
87
|
"dependencies": {
|
|
83
88
|
"@cucumber/tag-expressions": "^6.2.0",
|
|
84
89
|
"@faker-js/faker": "^9.8.0",
|
|
@@ -96,10 +101,12 @@
|
|
|
96
101
|
"eslint": "^9.29.0",
|
|
97
102
|
"eslint-config-prettier": "^10.1.5",
|
|
98
103
|
"eslint-plugin-import": "^2.32.0",
|
|
104
|
+
"gh-pages": "^6.3.0",
|
|
99
105
|
"husky": "^9.1.7",
|
|
100
106
|
"lint-staged": "^16.1.2",
|
|
101
107
|
"prettier": "^3.5.3",
|
|
102
108
|
"ts-node": "^10.9.2",
|
|
109
|
+
"typedoc": "^0.28.5",
|
|
103
110
|
"typescript": "^5.8.3",
|
|
104
111
|
"typescript-eslint": "^8.34.1"
|
|
105
112
|
}
|