Repository: pactumjs/pactum
Pull request #284 (2023-05-27 09:47:12)

disable use interaction


Patch:
diff --git a/package-lock.json b/package-lock.json
index 9787ab4..4deda0b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
   "name": "pactum",
-  "version": "3.4.0",
+  "version": "3.4.1",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
@@ -1666,9 +1666,9 @@
       }
     },
     "pactum-matchers": {
-      "version": "1.1.4",
-      "resolved": "https://registry.npmjs.org/pactum-matchers/-/pactum-matchers-1.1.4.tgz",
-      "integrity": "sha512-GkIrdBQyFlmKb7LEcSSmkALnGFuZTRTS3C6q46e1uWHAtuwRqB/Mbeg4ta8nZ7eVUglJDG4pUYpZgpVVqycUNQ=="
+      "version": "1.1.5",
+      "resolved": "https://registry.npmjs.org/pactum-matchers/-/pactum-matchers-1.1.5.tgz",
+      "integrity": "sha512-Bc9VVmCYeTFLRw+Du/i8MJl8jA0iBP1pbhYg45+shrKkZJbhSTsrL8ZyAKLuGeFnO0e1HG1c7u6O9Cua30a9cg=="
     },
     "parse-graphql": {
       "version": "1.0.0",
diff --git a/package.json b/package.json
index ae795e9..3beb6de 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "pactum",
-  "version": "3.4.0",
+  "version": "3.4.1",
   "description": "REST API Testing Tool for all levels in a Test Pyramid",
   "main": "./src/index.js",
   "types": "./src/index.d.ts",
@@ -59,7 +59,7 @@
     "klona": "^2.0.5",
     "lightcookie": "^1.0.25",
     "openapi-fuzzer-core": "^1.0.6",
-    "pactum-matchers": "^1.1.4",
+    "pactum-matchers": "^1.1.5",
     "parse-graphql": "^1.0.0",
     "phin": "^3.7.0",
     "polka": "^0.5.2"
diff --git a/src/config.js b/src/config.js
index 0893c54..d797895 100644
--- a/src/config.js
+++ b/src/config.js
@@ -12,7 +12,8 @@ const config = {
     retry: {
       count: 1,
       delay: 1000
-    }
+    },
+    disable_use_interaction: process.env.PACTUM_DISABLE_USE_INTERACTION || false,
   },
   response: {
     time: process.env.PACTUM_RESPONSE_TIME ? parseInt(process.env.PACTUM_RESPONSE_TIME) : null,
diff --git a/src/models/Spec.js b/src/models/Spec.js
index fd6e142..364a24e 100644
--- a/src/models/Spec.js
+++ b/src/models/Spec.js
@@ -1,4 +1,3 @@
-const fd = require('../plugins/form.data')
 const fs = require('fs');
 const lc = require('lightcookie');
 
@@ -14,6 +13,7 @@ const { PactumRequestError } = require('../helpers/errors');
 const responseExpect = require('../exports/expect');
 const hr = require('../helpers/handler.runner');
 const rlc = require('../helpers/reporter.lifeCycle');
+const config = require('../config');
 
 class Spec {
   constructor(name, data) {
@@ -57,6 +57,9 @@ class Spec {
   }
 
   useInteraction(interaction, data) {
+    if (config.request.disable_use_interaction) {
+      return this;
+    }
     this.interactions.push({ interaction, data });
     return this;
   }


Test patch:
diff --git a/test/unit/spec.spec.js b/test/unit/spec.spec.js
index 8dee98a..b581d59 100644
--- a/test/unit/spec.spec.js
+++ b/test/unit/spec.spec.js
@@ -1,4 +1,5 @@
 const expect = require('chai').expect;
+const config = require('../../src/config');
 
 const Spec = require('../../src/models/Spec');
 
@@ -251,4 +252,12 @@ describe('Spec', () => {
     expect(spec._name).equals('Custom Name');
   });
 
+  it('disable use interaction', async () => {
+    config.request.disable_use_interaction = true;
+    const spec = new Spec();
+    spec.useInteraction('Custom Name');
+    expect(spec.interactions).deep.equals([]);
+    config.request.disable_use_interaction = false;
+  })
+
 });
\ No newline at end of file