playwright-cucumber-ts-steps 1.3.3 → 1.3.4
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/backend/api/assertions.d.ts +61 -1
- package/dist/backend/api/assertions.d.ts.map +1 -1
- package/dist/backend/api/assertions.js +202 -2
- package/dist/backend/utils/faker.d.ts +2 -0
- package/dist/backend/utils/faker.d.ts.map +1 -0
- package/dist/backend/utils/faker.js +510 -0
- package/dist/backend/utils/fixtures.d.ts +22 -2
- package/dist/backend/utils/fixtures.d.ts.map +1 -1
- package/dist/backend/utils/fixtures.js +247 -5
- package/dist/backend/utils/resolver.d.ts +13 -0
- package/dist/backend/utils/resolver.d.ts.map +1 -1
- package/dist/backend/utils/resolver.js +55 -0
- package/dist/core/runner.d.ts +1 -0
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/metadata.json +49 -1
- package/package.json +4 -2
|
@@ -2,17 +2,77 @@
|
|
|
2
2
|
* Asserts that the HTTP status code of the last API response matches the expected integer.
|
|
3
3
|
* @example Then I pw expect the response status to be 200
|
|
4
4
|
*/
|
|
5
|
-
export declare function expectResponseStatus(page: any, statusCode:
|
|
5
|
+
export declare function expectResponseStatus(page: any, statusCode: string): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Asserts that the HTTP status code of the last API response is successful (2xx).
|
|
8
|
+
* @example Then I pw expect the response status to be successful
|
|
9
|
+
*/
|
|
10
|
+
export declare function expectResponseStatusSuccess(_page: any): Promise<void>;
|
|
6
11
|
/**
|
|
7
12
|
* Asserts that the body text of the last API response contains a specific substring.
|
|
8
13
|
* Supports fixtures for reusable substrings.
|
|
9
14
|
* @example Then I pw expect the response body to contain "success"
|
|
10
15
|
*/
|
|
11
16
|
export declare function expectResponseBodyContain(page: any, textKey: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Asserts that the body text of the last API response does NOT contain a specific substring.
|
|
19
|
+
* @example Then I pw expect the response body to not contain "error"
|
|
20
|
+
*/
|
|
21
|
+
export declare function expectResponseBodyNotContain(page: any, textKey: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Asserts that the body text of the last API response equals a specific string.
|
|
24
|
+
* @example Then I pw expect the response body to equal "OK"
|
|
25
|
+
*/
|
|
26
|
+
export declare function expectResponseBodyEqual(page: any, textKey: string): Promise<void>;
|
|
12
27
|
/**
|
|
13
28
|
* Asserts that a specific property in the JSON response matches a string value.
|
|
14
29
|
* Supports dot notation for nested properties and fixtures for reusable keys/values.
|
|
15
30
|
* @example Then I pw expect the response property "user.id" to be "12345"
|
|
16
31
|
*/
|
|
17
32
|
export declare function expectResponseProperty(page: any, jsonPathKey: string, valueKey: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Stores a response property value in the variable store for later use.
|
|
35
|
+
* @example When I pw store response property "user.id" value as "userId"
|
|
36
|
+
*/
|
|
37
|
+
export declare function storeResponseProperty(page: any, jsonPathKey: string, alias: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Asserts that a response property exists in the JSON response.
|
|
40
|
+
* @example Then I pw expect response property "user.email" to exist
|
|
41
|
+
*/
|
|
42
|
+
export declare function expectResponsePropertyExists(page: any, jsonPathKey: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Asserts that a response property does NOT exist in the JSON response.
|
|
45
|
+
* @example Then I pw expect response property "user.deletedAt" to not exist
|
|
46
|
+
*/
|
|
47
|
+
export declare function expectResponsePropertyNotExists(page: any, jsonPathKey: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Asserts that a response property is null.
|
|
50
|
+
* @example Then I pw expect response property "user.deletedAt" to be null
|
|
51
|
+
*/
|
|
52
|
+
export declare function expectResponsePropertyBeNull(page: any, jsonPathKey: string): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Asserts that a response property is not null.
|
|
55
|
+
* @example Then I pw expect response property "user.id" to not be null
|
|
56
|
+
*/
|
|
57
|
+
export declare function expectResponsePropertyNotNull(page: any, jsonPathKey: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Asserts that a response property contains a substring.
|
|
60
|
+
* @example Then I pw expect response property "user.email" to contain "@example.com"
|
|
61
|
+
*/
|
|
62
|
+
export declare function expectResponsePropertyContains(page: any, jsonPathKey: string, substring: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Asserts that a response array property has a specific length.
|
|
65
|
+
* @example Then I pw expect response property "users" array length to be 10
|
|
66
|
+
*/
|
|
67
|
+
export declare function expectResponseArrayLength(page: any, jsonPathKey: string, expectedLength: number): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Asserts that a response array property is not empty.
|
|
70
|
+
* @example Then I pw expect response property "users" array to not be empty
|
|
71
|
+
*/
|
|
72
|
+
export declare function expectResponseArrayNotEmpty(page: any, jsonPathKey: string): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Fills an input field with a previously stored value.
|
|
75
|
+
* @example When I pw fill "#userId" with stored value "userId"
|
|
76
|
+
*/
|
|
77
|
+
export declare function fillWithStoredValue(page: any, selector: string, alias: string): Promise<void>;
|
|
18
78
|
//# sourceMappingURL=assertions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../../src/backend/api/assertions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../../src/backend/api/assertions.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKvF;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAO3E;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUzF;AAED;;;GAGG;AACH,wBAAsB,4BAA4B,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAU5F;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUvF;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,GAAG,EACT,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAef;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYxG;AAED;;;GAGG;AACH,wBAAsB,4BAA4B,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYhG;AAED;;;GAGG;AACH,wBAAsB,+BAA+B,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYnG;AAED;;;GAGG;AACH,wBAAsB,4BAA4B,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYhG;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYjG;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYrH;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAarH;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAa/F;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOnG"}
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.expectResponseStatus = expectResponseStatus;
|
|
4
|
+
exports.expectResponseStatusSuccess = expectResponseStatusSuccess;
|
|
4
5
|
exports.expectResponseBodyContain = expectResponseBodyContain;
|
|
6
|
+
exports.expectResponseBodyNotContain = expectResponseBodyNotContain;
|
|
7
|
+
exports.expectResponseBodyEqual = expectResponseBodyEqual;
|
|
5
8
|
exports.expectResponseProperty = expectResponseProperty;
|
|
9
|
+
exports.storeResponseProperty = storeResponseProperty;
|
|
10
|
+
exports.expectResponsePropertyExists = expectResponsePropertyExists;
|
|
11
|
+
exports.expectResponsePropertyNotExists = expectResponsePropertyNotExists;
|
|
12
|
+
exports.expectResponsePropertyBeNull = expectResponsePropertyBeNull;
|
|
13
|
+
exports.expectResponsePropertyNotNull = expectResponsePropertyNotNull;
|
|
14
|
+
exports.expectResponsePropertyContains = expectResponsePropertyContains;
|
|
15
|
+
exports.expectResponseArrayLength = expectResponseArrayLength;
|
|
16
|
+
exports.expectResponseArrayNotEmpty = expectResponseArrayNotEmpty;
|
|
17
|
+
exports.fillWithStoredValue = fillWithStoredValue;
|
|
6
18
|
//src/backend/api/assertions.ts
|
|
7
19
|
const test_1 = require("@playwright/test");
|
|
8
20
|
const registry_1 = require("../../core/registry");
|
|
9
21
|
const state_1 = require("../utils/state");
|
|
10
22
|
const fixtures_1 = require("../utils/fixtures");
|
|
23
|
+
const state_2 = require("../utils/state");
|
|
11
24
|
// ==================================================
|
|
12
25
|
// CORE FUNCTIONS
|
|
13
26
|
// ==================================================
|
|
@@ -19,9 +32,22 @@ async function expectResponseStatus(page, statusCode) {
|
|
|
19
32
|
const response = state_1.apiState.getResponse();
|
|
20
33
|
if (!response)
|
|
21
34
|
throw new Error("❌ No API response found. Did you forget to make a request?");
|
|
22
|
-
(0, test_1.expect)(response.status()).toBe(statusCode);
|
|
35
|
+
(0, test_1.expect)(String(response.status())).toBe(String(statusCode));
|
|
23
36
|
console.log(`✅ Response status is ${statusCode}`);
|
|
24
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Asserts that the HTTP status code of the last API response is successful (2xx).
|
|
40
|
+
* @example Then I pw expect the response status to be successful
|
|
41
|
+
*/
|
|
42
|
+
async function expectResponseStatusSuccess(_page) {
|
|
43
|
+
const response = state_1.apiState.getResponse();
|
|
44
|
+
if (!response)
|
|
45
|
+
throw new Error("❌ No API response found. Did you forget to make a request?");
|
|
46
|
+
const status = response.status();
|
|
47
|
+
(0, test_1.expect)(status).toBeGreaterThanOrEqual(200);
|
|
48
|
+
(0, test_1.expect)(status).toBeLessThan(300);
|
|
49
|
+
console.log(`✅ Response status ${status} is successful`);
|
|
50
|
+
}
|
|
25
51
|
/**
|
|
26
52
|
* Asserts that the body text of the last API response contains a specific substring.
|
|
27
53
|
* Supports fixtures for reusable substrings.
|
|
@@ -37,6 +63,34 @@ async function expectResponseBodyContain(page, textKey) {
|
|
|
37
63
|
(0, test_1.expect)(body).toContain(text);
|
|
38
64
|
console.log(`✅ Response body contains "${text}"`);
|
|
39
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Asserts that the body text of the last API response does NOT contain a specific substring.
|
|
68
|
+
* @example Then I pw expect the response body to not contain "error"
|
|
69
|
+
*/
|
|
70
|
+
async function expectResponseBodyNotContain(page, textKey) {
|
|
71
|
+
const response = state_1.apiState.getResponse();
|
|
72
|
+
if (!response)
|
|
73
|
+
throw new Error("❌ No API response found. Did you forget to make a request?");
|
|
74
|
+
const texts = (0, fixtures_1.loadFixture)("responses.json");
|
|
75
|
+
const text = (0, fixtures_1.getFixtureValue)(texts, textKey);
|
|
76
|
+
const body = await response.text();
|
|
77
|
+
(0, test_1.expect)(body).not.toContain(text);
|
|
78
|
+
console.log(`✅ Response body does not contain "${text}"`);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Asserts that the body text of the last API response equals a specific string.
|
|
82
|
+
* @example Then I pw expect the response body to equal "OK"
|
|
83
|
+
*/
|
|
84
|
+
async function expectResponseBodyEqual(page, textKey) {
|
|
85
|
+
const response = state_1.apiState.getResponse();
|
|
86
|
+
if (!response)
|
|
87
|
+
throw new Error("❌ No API response found. Did you forget to make a request?");
|
|
88
|
+
const texts = (0, fixtures_1.loadFixture)("responses.json");
|
|
89
|
+
const text = (0, fixtures_1.getFixtureValue)(texts, textKey);
|
|
90
|
+
const body = await response.text();
|
|
91
|
+
(0, test_1.expect)(body).toBe(text);
|
|
92
|
+
console.log(`✅ Response body equals "${text}"`);
|
|
93
|
+
}
|
|
40
94
|
/**
|
|
41
95
|
* Asserts that a specific property in the JSON response matches a string value.
|
|
42
96
|
* Supports dot notation for nested properties and fixtures for reusable keys/values.
|
|
@@ -55,9 +109,155 @@ async function expectResponseProperty(page, jsonPathKey, valueKey) {
|
|
|
55
109
|
(0, test_1.expect)(String(actualValue)).toBe(expectedValue);
|
|
56
110
|
console.log(`✅ Response property "${jsonPath}" is "${expectedValue}"`);
|
|
57
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Stores a response property value in the variable store for later use.
|
|
114
|
+
* @example When I pw store response property "user.id" value as "userId"
|
|
115
|
+
*/
|
|
116
|
+
async function storeResponseProperty(page, jsonPathKey, alias) {
|
|
117
|
+
const response = state_1.apiState.getResponse();
|
|
118
|
+
if (!response)
|
|
119
|
+
throw new Error("❌ No API response found. Did you forget to make a request?");
|
|
120
|
+
const paths = (0, fixtures_1.loadFixture)("paths.json");
|
|
121
|
+
const jsonPath = (0, fixtures_1.getFixtureValue)(paths, jsonPathKey);
|
|
122
|
+
const json = await response.json();
|
|
123
|
+
const value = jsonPath.split(".").reduce((o, i) => o[i], json);
|
|
124
|
+
(0, state_2.setVariable)(page, alias, value);
|
|
125
|
+
console.log(`💾 Stored response property "${jsonPath}" = "${value}" as @${alias}`);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Asserts that a response property exists in the JSON response.
|
|
129
|
+
* @example Then I pw expect response property "user.email" to exist
|
|
130
|
+
*/
|
|
131
|
+
async function expectResponsePropertyExists(page, jsonPathKey) {
|
|
132
|
+
const response = state_1.apiState.getResponse();
|
|
133
|
+
if (!response)
|
|
134
|
+
throw new Error("❌ No API response found. Did you forget to make a request?");
|
|
135
|
+
const paths = (0, fixtures_1.loadFixture)("paths.json");
|
|
136
|
+
const jsonPath = (0, fixtures_1.getFixtureValue)(paths, jsonPathKey);
|
|
137
|
+
const json = await response.json();
|
|
138
|
+
const value = jsonPath.split(".").reduce((o, i) => o && i in o ? o[i] : undefined, json);
|
|
139
|
+
(0, test_1.expect)(value).toBeDefined();
|
|
140
|
+
console.log(`✅ Response property "${jsonPath}" exists`);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Asserts that a response property does NOT exist in the JSON response.
|
|
144
|
+
* @example Then I pw expect response property "user.deletedAt" to not exist
|
|
145
|
+
*/
|
|
146
|
+
async function expectResponsePropertyNotExists(page, jsonPathKey) {
|
|
147
|
+
const response = state_1.apiState.getResponse();
|
|
148
|
+
if (!response)
|
|
149
|
+
throw new Error("❌ No API response found. Did you forget to make a request?");
|
|
150
|
+
const paths = (0, fixtures_1.loadFixture)("paths.json");
|
|
151
|
+
const jsonPath = (0, fixtures_1.getFixtureValue)(paths, jsonPathKey);
|
|
152
|
+
const json = await response.json();
|
|
153
|
+
const value = jsonPath.split(".").reduce((o, i) => o && i in o ? o[i] : undefined, json);
|
|
154
|
+
(0, test_1.expect)(value).toBeUndefined();
|
|
155
|
+
console.log(`✅ Response property "${jsonPath}" does not exist`);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Asserts that a response property is null.
|
|
159
|
+
* @example Then I pw expect response property "user.deletedAt" to be null
|
|
160
|
+
*/
|
|
161
|
+
async function expectResponsePropertyBeNull(page, jsonPathKey) {
|
|
162
|
+
const response = state_1.apiState.getResponse();
|
|
163
|
+
if (!response)
|
|
164
|
+
throw new Error("❌ No API response found. Did you forget to make a request?");
|
|
165
|
+
const paths = (0, fixtures_1.loadFixture)("paths.json");
|
|
166
|
+
const jsonPath = (0, fixtures_1.getFixtureValue)(paths, jsonPathKey);
|
|
167
|
+
const json = await response.json();
|
|
168
|
+
const value = jsonPath.split(".").reduce((o, i) => o && i in o ? o[i] : undefined, json);
|
|
169
|
+
(0, test_1.expect)(value).toBeNull();
|
|
170
|
+
console.log(`✅ Response property "${jsonPath}" is null`);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Asserts that a response property is not null.
|
|
174
|
+
* @example Then I pw expect response property "user.id" to not be null
|
|
175
|
+
*/
|
|
176
|
+
async function expectResponsePropertyNotNull(page, jsonPathKey) {
|
|
177
|
+
const response = state_1.apiState.getResponse();
|
|
178
|
+
if (!response)
|
|
179
|
+
throw new Error("❌ No API response found. Did you forget to make a request?");
|
|
180
|
+
const paths = (0, fixtures_1.loadFixture)("paths.json");
|
|
181
|
+
const jsonPath = (0, fixtures_1.getFixtureValue)(paths, jsonPathKey);
|
|
182
|
+
const json = await response.json();
|
|
183
|
+
const value = jsonPath.split(".").reduce((o, i) => o && i in o ? o[i] : undefined, json);
|
|
184
|
+
(0, test_1.expect)(value).not.toBeNull();
|
|
185
|
+
console.log(`✅ Response property "${jsonPath}" is not null`);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Asserts that a response property contains a substring.
|
|
189
|
+
* @example Then I pw expect response property "user.email" to contain "@example.com"
|
|
190
|
+
*/
|
|
191
|
+
async function expectResponsePropertyContains(page, jsonPathKey, substring) {
|
|
192
|
+
const response = state_1.apiState.getResponse();
|
|
193
|
+
if (!response)
|
|
194
|
+
throw new Error("❌ No API response found. Did you forget to make a request?");
|
|
195
|
+
const paths = (0, fixtures_1.loadFixture)("paths.json");
|
|
196
|
+
const jsonPath = (0, fixtures_1.getFixtureValue)(paths, jsonPathKey);
|
|
197
|
+
const json = await response.json();
|
|
198
|
+
const value = jsonPath.split(".").reduce((o, i) => o && i in o ? o[i] : undefined, json);
|
|
199
|
+
(0, test_1.expect)(String(value)).toContain(substring);
|
|
200
|
+
console.log(`✅ Response property "${jsonPath}" contains "${substring}"`);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Asserts that a response array property has a specific length.
|
|
204
|
+
* @example Then I pw expect response property "users" array length to be 10
|
|
205
|
+
*/
|
|
206
|
+
async function expectResponseArrayLength(page, jsonPathKey, expectedLength) {
|
|
207
|
+
const response = state_1.apiState.getResponse();
|
|
208
|
+
if (!response)
|
|
209
|
+
throw new Error("❌ No API response found. Did you forget to make a request?");
|
|
210
|
+
const paths = (0, fixtures_1.loadFixture)("paths.json");
|
|
211
|
+
const jsonPath = (0, fixtures_1.getFixtureValue)(paths, jsonPathKey);
|
|
212
|
+
const json = await response.json();
|
|
213
|
+
const value = jsonPath.split(".").reduce((o, i) => o && i in o ? o[i] : undefined, json);
|
|
214
|
+
(0, test_1.expect)(Array.isArray(value)).toBe(true);
|
|
215
|
+
(0, test_1.expect)(value.length).toBe(expectedLength);
|
|
216
|
+
console.log(`✅ Response property "${jsonPath}" array length is ${expectedLength}`);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Asserts that a response array property is not empty.
|
|
220
|
+
* @example Then I pw expect response property "users" array to not be empty
|
|
221
|
+
*/
|
|
222
|
+
async function expectResponseArrayNotEmpty(page, jsonPathKey) {
|
|
223
|
+
const response = state_1.apiState.getResponse();
|
|
224
|
+
if (!response)
|
|
225
|
+
throw new Error("❌ No API response found. Did you forget to make a request?");
|
|
226
|
+
const paths = (0, fixtures_1.loadFixture)("paths.json");
|
|
227
|
+
const jsonPath = (0, fixtures_1.getFixtureValue)(paths, jsonPathKey);
|
|
228
|
+
const json = await response.json();
|
|
229
|
+
const value = jsonPath.split(".").reduce((o, i) => o && i in o ? o[i] : undefined, json);
|
|
230
|
+
(0, test_1.expect)(Array.isArray(value)).toBe(true);
|
|
231
|
+
(0, test_1.expect)(value.length).toBeGreaterThan(0);
|
|
232
|
+
console.log(`✅ Response property "${jsonPath}" array is not empty`);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Fills an input field with a previously stored value.
|
|
236
|
+
* @example When I pw fill "#userId" with stored value "userId"
|
|
237
|
+
*/
|
|
238
|
+
async function fillWithStoredValue(page, selector, alias) {
|
|
239
|
+
const value = (0, state_2.getVariable)(page, alias);
|
|
240
|
+
if (value === undefined) {
|
|
241
|
+
throw new Error(`❌ No stored value found for alias "@${alias}"`);
|
|
242
|
+
}
|
|
243
|
+
await page.fill(selector, String(value));
|
|
244
|
+
console.log(`✍️ Filled "${selector}" with stored value @${alias} = "${value}"`);
|
|
245
|
+
}
|
|
58
246
|
// ==================================================
|
|
59
247
|
// GLUE STEPS
|
|
60
248
|
// ==================================================
|
|
61
|
-
(0, registry_1.Step)("I pw expect the response status to be {
|
|
249
|
+
(0, registry_1.Step)("I pw expect the response status to be {string}", expectResponseStatus, "Then");
|
|
250
|
+
(0, registry_1.Step)("I pw expect the response status to be successful", expectResponseStatusSuccess, "Then");
|
|
62
251
|
(0, registry_1.Step)("I pw expect the response body to contain {string}", expectResponseBodyContain, "Then");
|
|
252
|
+
(0, registry_1.Step)("I pw expect the response body to not contain {string}", expectResponseBodyNotContain, "Then");
|
|
253
|
+
(0, registry_1.Step)("I pw expect the response body to equal {string}", expectResponseBodyEqual, "Then");
|
|
63
254
|
(0, registry_1.Step)("I pw expect the response property {string} to be {string}", expectResponseProperty, "Then");
|
|
255
|
+
(0, registry_1.Step)("I pw store response property {string} value as {string}", storeResponseProperty, "When");
|
|
256
|
+
(0, registry_1.Step)("I pw expect response property {string} to exist", expectResponsePropertyExists, "Then");
|
|
257
|
+
(0, registry_1.Step)("I pw expect response property {string} to not exist", expectResponsePropertyNotExists, "Then");
|
|
258
|
+
(0, registry_1.Step)("I pw expect response property {string} to be null", expectResponsePropertyBeNull, "Then");
|
|
259
|
+
(0, registry_1.Step)("I pw expect response property {string} to not be null", expectResponsePropertyNotNull, "Then");
|
|
260
|
+
(0, registry_1.Step)("I pw expect response property {string} to contain {string}", expectResponsePropertyContains, "Then");
|
|
261
|
+
(0, registry_1.Step)("I pw expect response property {string} array length to be {int}", expectResponseArrayLength, "Then");
|
|
262
|
+
(0, registry_1.Step)("I pw expect response property {string} array to not be empty", expectResponseArrayNotEmpty, "Then");
|
|
263
|
+
(0, registry_1.Step)("I pw fill {string} with stored value {string}", fillWithStoredValue, "When");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"faker.d.ts","sourceRoot":"","sources":["../../../src/backend/utils/faker.ts"],"names":[],"mappings":""}
|