artes 1.0.73 → 1.0.74

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/hooks/hooks.js +22 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.0.73",
3
+ "version": "1.0.74",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -3,7 +3,7 @@ const {
3
3
  Before,
4
4
  After,
5
5
  Status,
6
- setDefaultTimeout,
6
+ setDefaultTimeout, AfterStep
7
7
  } = require("@cucumber/cucumber");
8
8
  const { invokeBrowser } = require("../helper/contextManager/browserManager");
9
9
  const { invokeRequest } = require("../helper/contextManager/requestManager");
@@ -40,6 +40,27 @@ Before(async function () {
40
40
  });
41
41
  });
42
42
 
43
+ AfterStep(async function ({pickleStep}) {
44
+ const stepText = pickleStep.text;
45
+
46
+ const methods = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'];
47
+
48
+ if( methods.some(method => stepText.includes(method))){
49
+ if (context.response) {
50
+ for (const [key, value] of Object.entries(context.response)) {
51
+ let text = `${key}:\n`;
52
+
53
+ if (typeof value === 'object') {
54
+ text += JSON.stringify(value, null, 2);
55
+ } else {
56
+ text += value;
57
+ }
58
+
59
+ await this.attach(text, "text/plain");
60
+ }
61
+ }}
62
+ })
63
+
43
64
  After(async function ({ pickle, result }) {
44
65
  if (result?.status != Status.PASSED) {
45
66
  let img = await context.page.screenshot({