playwright-cucumber-ts-steps 0.0.7 → 0.0.8
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright-cucumber-ts-steps",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
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": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { When, Then } from "@cucumber/cucumber";
|
|
2
|
-
When("I intercept URL {string}", async function (url) {
|
|
3
|
-
await this.page.route(url, async (route) => {
|
|
4
|
-
await route.continue();
|
|
5
|
-
});
|
|
6
|
-
});
|
|
7
|
-
When("I intercept URL {string} and stub body {string}", async function (url, body) {
|
|
8
|
-
await this.page.route(url, (route) => {
|
|
9
|
-
route.fulfill({
|
|
10
|
-
status: 200,
|
|
11
|
-
contentType: "application/json",
|
|
12
|
-
body,
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
When("I make a request to {string}", async function (url) {
|
|
17
|
-
const response = await this.page.request.get(url);
|
|
18
|
-
this.data.lastResponse = response;
|
|
19
|
-
});
|
|
20
|
-
Then("I see response status {int}", async function (status) {
|
|
21
|
-
const res = this.data.lastResponse;
|
|
22
|
-
if (!res)
|
|
23
|
-
throw new Error("No response available");
|
|
24
|
-
const actual = res.status();
|
|
25
|
-
if (actual !== status)
|
|
26
|
-
throw new Error(`Expected status ${status}, got ${actual}`);
|
|
27
|
-
});
|
|
28
|
-
Then("I see response body {string}", async function (expected) {
|
|
29
|
-
const res = this.data.lastResponse;
|
|
30
|
-
const body = await res.text();
|
|
31
|
-
if (body !== expected)
|
|
32
|
-
throw new Error(`Expected body "${expected}", got "${body}"`);
|
|
33
|
-
});
|
|
34
|
-
Then("I see response body contains {string}", async function (part) {
|
|
35
|
-
const res = this.data.lastResponse;
|
|
36
|
-
const body = await res.text();
|
|
37
|
-
if (!body.includes(part))
|
|
38
|
-
throw new Error(`Body does not contain "${part}"`);
|
|
39
|
-
});
|