From 98f07f8a4c002926e24676af45067d911b589b58 Mon Sep 17 00:00:00 2001
From: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
Date: Wed, 12 Nov 2025 13:53:10 +0530
Subject: [PATCH] test(js-sandbox): expand unsupported API coverage and sync
error messages
Add comprehensive test coverage for unsupported Postman APIs and ensure
consistent error messages across pre-request and post-request contexts.
Test improvements:
- Expand coverage from 13 to 25 unsupported APIs (50 tests total)
- Add missing APIs: collectionVariables.set/unset/has/clear/toObject,
vault.set/unset, iterationData.set/unset/has/toJSON
- Fix assertions to match actual error format with prefix
- Add pre-request context test for pm.execution.location
Implementation fixes:
- Add missing pm.iterationData.toJSON() in pre-request.js
- Sync post-request.js collectionVariables error messages to match
pre-request.js ("use environment or request variables instead")
---
.../collections/scripting-revamp-coll.json | 2 +-
.../src/types/pre-request.d.ts | 24 +-
.../__tests__/pm-namespace/execution.spec.ts | 73 +++
.../pm-namespace/unsupported.spec.ts | 456 +++++++-----------
.../src/bootstrap-code/post-request.js | 14 +-
.../src/bootstrap-code/pre-request.js | 39 +-
6 files changed, 315 insertions(+), 293 deletions(-)
create mode 100644 packages/hoppscotch-js-sandbox/src/__tests__/pm-namespace/execution.spec.ts
diff --git a/packages/hoppscotch-cli/src/__tests__/e2e/fixtures/collections/scripting-revamp-coll.json b/packages/hoppscotch-cli/src/__tests__/e2e/fixtures/collections/scripting-revamp-coll.json
index c513f23a..26a56548 100644
--- a/packages/hoppscotch-cli/src/__tests__/e2e/fixtures/collections/scripting-revamp-coll.json
+++ b/packages/hoppscotch-cli/src/__tests__/e2e/fixtures/collections/scripting-revamp-coll.json
@@ -576,7 +576,7 @@
"params": [],
"headers": [],
"preRequestScript": "export {};\n",
- "testScript": "export {};\n\npm.test('pm.require() throws descriptive error', () => {\n const throwFn = () => pm.require('lodash')\n pm.expect(throwFn).to.throw()\n pm.expect(throwFn).to.throw(/not supported in Hoppscotch/)\n})\n\npm.test('pm.execution.runRequest() throws descriptive error', () => {\n const throwFn = () => pm.execution.runRequest()\n pm.expect(throwFn).to.throw()\n pm.expect(throwFn).to.throw(/Collection Runner feature/)\n})\n\npm.test('pm.collectionVariables.replaceIn() throws descriptive error', () => {\n const throwFn = () => pm.collectionVariables.replaceIn('{{test}}')\n pm.expect(throwFn).to.throw()\n pm.expect(throwFn).to.throw(/Workspace feature/)\n})\n\npm.test('pm.iterationData.toJSON() throws descriptive error', () => {\n const throwFn = () => pm.iterationData.toJSON()\n pm.expect(throwFn).to.throw()\n pm.expect(throwFn).to.throw(/Collection Runner feature/)\n})\n",
+ "testScript": "export {};\n\nconst unsupportedApis = [\n { api: 'pm.info.iteration', script: () => { const x = pm.info.iteration }, errorMessage: /Collection Runner feature/ },\n { api: 'pm.info.iterationCount', script: () => { const x = pm.info.iterationCount }, errorMessage: /Collection Runner feature/ },\n { api: 'pm.collectionVariables.get()', script: () => pm.collectionVariables.get('test'), errorMessage: /use environment or request variables instead/ },\n { api: 'pm.collectionVariables.set()', script: () => pm.collectionVariables.set('key', 'value'), errorMessage: /use environment or request variables instead/ },\n { api: 'pm.collectionVariables.unset()', script: () => pm.collectionVariables.unset('key'), errorMessage: /use environment or request variables instead/ },\n { api: 'pm.collectionVariables.has()', script: () => pm.collectionVariables.has('key'), errorMessage: /use environment or request variables instead/ },\n { api: 'pm.collectionVariables.clear()', script: () => pm.collectionVariables.clear(), errorMessage: /use environment or request variables instead/ },\n { api: 'pm.collectionVariables.toObject()', script: () => pm.collectionVariables.toObject(), errorMessage: /use environment or request variables instead/ },\n { api: 'pm.collectionVariables.replaceIn()', script: () => pm.collectionVariables.replaceIn('{{test}}'), errorMessage: /use environment or request variables instead/ },\n { api: 'pm.vault.get()', script: () => pm.vault.get('test'), errorMessage: /Postman Vault feature/ },\n { api: 'pm.vault.set()', script: () => pm.vault.set('key', 'value'), errorMessage: /Postman Vault feature/ },\n { api: 'pm.vault.unset()', script: () => pm.vault.unset('key'), errorMessage: /Postman Vault feature/ },\n { api: 'pm.iterationData.get()', script: () => pm.iterationData.get('test'), errorMessage: /Collection Runner feature/ },\n { api: 'pm.iterationData.set()', script: () => pm.iterationData.set('key', 'value'), errorMessage: /Collection Runner feature/ },\n { api: 'pm.iterationData.unset()', script: () => pm.iterationData.unset('key'), errorMessage: /Collection Runner feature/ },\n { api: 'pm.iterationData.has()', script: () => pm.iterationData.has('key'), errorMessage: /Collection Runner feature/ },\n { api: 'pm.iterationData.toObject()', script: () => pm.iterationData.toObject(), errorMessage: /Collection Runner feature/ },\n { api: 'pm.iterationData.toJSON()', script: () => pm.iterationData.toJSON(), errorMessage: /Collection Runner feature/ },\n { api: 'pm.execution.setNextRequest()', script: () => pm.execution.setNextRequest('next'), errorMessage: /Collection Runner feature/ },\n { api: 'pm.execution.skipRequest()', script: () => pm.execution.skipRequest(), errorMessage: /Collection Runner feature/ },\n { api: 'pm.execution.runRequest()', script: () => pm.execution.runRequest(), errorMessage: /Collection Runner feature/ },\n { api: 'pm.sendRequest()', script: () => pm.sendRequest('https://example.com', () => {}), errorMessage: /not yet implemented/ },\n { api: 'pm.visualizer.set()', script: () => pm.visualizer.set('
Test
'), errorMessage: /Postman Visualizer feature/ },\n { api: 'pm.visualizer.clear()', script: () => pm.visualizer.clear(), errorMessage: /Postman Visualizer feature/ },\n { api: 'pm.require()', script: () => pm.require('lodash'), errorMessage: /not supported in Hoppscotch/ },\n]\n\nunsupportedApis.forEach(({ api, script, errorMessage }) => {\n pm.test(`${api} throws descriptive error`, () => {\n pm.expect(script).to.throw(errorMessage)\n })\n})\n",
"auth": {
"authType": "inherit",
"authActive": true
diff --git a/packages/hoppscotch-common/src/types/pre-request.d.ts b/packages/hoppscotch-common/src/types/pre-request.d.ts
index 7b781631..098f0595 100644
--- a/packages/hoppscotch-common/src/types/pre-request.d.ts
+++ b/packages/hoppscotch-common/src/types/pre-request.d.ts
@@ -816,7 +816,14 @@ declare namespace pm {
readonly iterationCount: never
}>
- const sendRequest: () => never
+ /**
+ * Send an HTTP request (unsupported)
+ * @throws Error - sendRequest is not supported in Hoppscotch
+ */
+ function sendRequest(
+ request: string | { url: string; method?: string; [key: string]: any },
+ callback?: (err: any, response: any) => void
+ ): never
/**
* Collection variables (unsupported - Workspace feature)
@@ -886,6 +893,13 @@ declare namespace pm {
* Execution control
*/
const execution: Readonly<{
+ /**
+ * Execution location identifier
+ * Always returns ["Hoppscotch"] with current = "Hoppscotch"
+ */
+ readonly location: readonly string[] & {
+ readonly current: string
+ }
/**
* Set next request to execute (unsupported - Collection Runner feature)
* @param requestNameOrId - Name or ID of the next request
@@ -901,4 +915,12 @@ declare namespace pm {
*/
runRequest(requestNameOrId: string): never
}>
+
+ /**
+ * Import packages from Package Library (unsupported)
+ * @param packageName - Name of the package to import (e.g., '@team-domain/package-name' or 'npm:package-name@version')
+ * @returns The imported package module
+ * @throws Error - Package imports are not supported in Hoppscotch
+ */
+ function require(packageName: string): never
}
diff --git a/packages/hoppscotch-js-sandbox/src/__tests__/pm-namespace/execution.spec.ts b/packages/hoppscotch-js-sandbox/src/__tests__/pm-namespace/execution.spec.ts
new file mode 100644
index 00000000..da721d15
--- /dev/null
+++ b/packages/hoppscotch-js-sandbox/src/__tests__/pm-namespace/execution.spec.ts
@@ -0,0 +1,73 @@
+import { describe, expect, test } from "vitest"
+import { runTest, runPreRequest } from "~/utils/test-helpers"
+
+describe("pm.execution namespace", () => {
+ test("pm.execution.location returns Hoppscotch array in test script", () => {
+ return expect(
+ runTest(
+ `
+ pm.test("pm.execution.location is an array", () => {
+ pm.expect(Array.isArray(pm.execution.location)).to.be.true
+ })
+
+ pm.test("pm.execution.location contains Hoppscotch", () => {
+ pm.expect(pm.execution.location).to.include("Hoppscotch")
+ })
+
+ pm.test("pm.execution.location.current is Hoppscotch", () => {
+ pm.expect(pm.execution.location.current).to.equal("Hoppscotch")
+ })
+ `,
+ {
+ global: [],
+ selected: [],
+ }
+ )()
+ ).resolves.toEqualRight([
+ expect.objectContaining({
+ children: [
+ expect.objectContaining({
+ descriptor: "pm.execution.location is an array",
+ expectResults: [{ status: "pass", message: expect.any(String) }],
+ }),
+ expect.objectContaining({
+ descriptor: "pm.execution.location contains Hoppscotch",
+ expectResults: [{ status: "pass", message: expect.any(String) }],
+ }),
+ expect.objectContaining({
+ descriptor: "pm.execution.location.current is Hoppscotch",
+ expectResults: [{ status: "pass", message: expect.any(String) }],
+ }),
+ ],
+ }),
+ ])
+ })
+
+ test("pm.execution.location is accessible in pre-request script", () => {
+ return expect(
+ runPreRequest(
+ `
+ // Verify pm.execution.location exists and has expected values
+ if (!Array.isArray(pm.execution.location)) {
+ throw new Error("pm.execution.location is not an array")
+ }
+ if (!pm.execution.location.includes("Hoppscotch")) {
+ throw new Error("pm.execution.location does not contain 'Hoppscotch'")
+ }
+ if (pm.execution.location.current !== "Hoppscotch") {
+ throw new Error("pm.execution.location.current is not 'Hoppscotch'")
+ }
+ `,
+ {
+ global: [],
+ selected: [],
+ }
+ )()
+ ).resolves.toEqualRight(
+ expect.objectContaining({
+ global: [],
+ selected: [],
+ })
+ )
+ })
+})
diff --git a/packages/hoppscotch-js-sandbox/src/__tests__/pm-namespace/unsupported.spec.ts b/packages/hoppscotch-js-sandbox/src/__tests__/pm-namespace/unsupported.spec.ts
index 490e4716..0c4b521b 100644
--- a/packages/hoppscotch-js-sandbox/src/__tests__/pm-namespace/unsupported.spec.ts
+++ b/packages/hoppscotch-js-sandbox/src/__tests__/pm-namespace/unsupported.spec.ts
@@ -1,292 +1,182 @@
import { describe, expect, test } from "vitest"
-import { runTest } from "~/utils/test-helpers"
+import { runTest, runPreRequest } from "~/utils/test-helpers"
+
+// Unified test data for unsupported APIs
+const unsupportedApis = [
+ {
+ api: "pm.info.iteration",
+ script: "const iteration = pm.info.iteration",
+ errorMessage:
+ "pm.info.iteration is not supported in Hoppscotch (Collection Runner feature)",
+ },
+ {
+ api: "pm.info.iterationCount",
+ script: "const iterationCount = pm.info.iterationCount",
+ errorMessage:
+ "pm.info.iterationCount is not supported in Hoppscotch (Collection Runner feature)",
+ },
+ {
+ api: "pm.collectionVariables.get()",
+ script: 'pm.collectionVariables.get("test")',
+ errorMessage:
+ "pm.collectionVariables.get() is not supported in Hoppscotch (use environment or request variables instead)",
+ },
+ {
+ api: "pm.collectionVariables.set()",
+ script: 'pm.collectionVariables.set("key", "value")',
+ errorMessage:
+ "pm.collectionVariables.set() is not supported in Hoppscotch (use environment or request variables instead)",
+ },
+ {
+ api: "pm.collectionVariables.unset()",
+ script: 'pm.collectionVariables.unset("key")',
+ errorMessage:
+ "pm.collectionVariables.unset() is not supported in Hoppscotch (use environment or request variables instead)",
+ },
+ {
+ api: "pm.collectionVariables.has()",
+ script: 'pm.collectionVariables.has("key")',
+ errorMessage:
+ "pm.collectionVariables.has() is not supported in Hoppscotch (use environment or request variables instead)",
+ },
+ {
+ api: "pm.collectionVariables.clear()",
+ script: "pm.collectionVariables.clear()",
+ errorMessage:
+ "pm.collectionVariables.clear() is not supported in Hoppscotch (use environment or request variables instead)",
+ },
+ {
+ api: "pm.collectionVariables.toObject()",
+ script: "pm.collectionVariables.toObject()",
+ errorMessage:
+ "pm.collectionVariables.toObject() is not supported in Hoppscotch (use environment or request variables instead)",
+ },
+ {
+ api: "pm.collectionVariables.replaceIn()",
+ script: 'pm.collectionVariables.replaceIn("{{var}}")',
+ errorMessage:
+ "pm.collectionVariables.replaceIn() is not supported in Hoppscotch (use environment or request variables instead)",
+ },
+ {
+ api: "pm.vault.get()",
+ script: 'pm.vault.get("test")',
+ errorMessage:
+ "pm.vault.get() is not supported in Hoppscotch (Postman Vault feature)",
+ },
+ {
+ api: "pm.vault.set()",
+ script: 'pm.vault.set("key", "value")',
+ errorMessage:
+ "pm.vault.set() is not supported in Hoppscotch (Postman Vault feature)",
+ },
+ {
+ api: "pm.vault.unset()",
+ script: 'pm.vault.unset("key")',
+ errorMessage:
+ "pm.vault.unset() is not supported in Hoppscotch (Postman Vault feature)",
+ },
+ {
+ api: "pm.iterationData.get()",
+ script: 'pm.iterationData.get("test")',
+ errorMessage:
+ "pm.iterationData.get() is not supported in Hoppscotch (Collection Runner feature)",
+ },
+ {
+ api: "pm.iterationData.set()",
+ script: 'pm.iterationData.set("key", "value")',
+ errorMessage:
+ "pm.iterationData.set() is not supported in Hoppscotch (Collection Runner feature)",
+ },
+ {
+ api: "pm.iterationData.unset()",
+ script: 'pm.iterationData.unset("key")',
+ errorMessage:
+ "pm.iterationData.unset() is not supported in Hoppscotch (Collection Runner feature)",
+ },
+ {
+ api: "pm.iterationData.has()",
+ script: 'pm.iterationData.has("key")',
+ errorMessage:
+ "pm.iterationData.has() is not supported in Hoppscotch (Collection Runner feature)",
+ },
+ {
+ api: "pm.iterationData.toObject()",
+ script: "pm.iterationData.toObject()",
+ errorMessage:
+ "pm.iterationData.toObject() is not supported in Hoppscotch (Collection Runner feature)",
+ },
+ {
+ api: "pm.iterationData.toJSON()",
+ script: "pm.iterationData.toJSON()",
+ errorMessage:
+ "pm.iterationData.toJSON() is not supported in Hoppscotch (Collection Runner feature)",
+ },
+ {
+ api: "pm.execution.setNextRequest()",
+ script: 'pm.execution.setNextRequest("next-request")',
+ errorMessage:
+ "pm.execution.setNextRequest() is not supported in Hoppscotch (Collection Runner feature)",
+ },
+ {
+ api: "pm.execution.skipRequest()",
+ script: "pm.execution.skipRequest()",
+ errorMessage:
+ "pm.execution.skipRequest() is not supported in Hoppscotch (Collection Runner feature)",
+ },
+ {
+ api: "pm.execution.runRequest()",
+ script: 'pm.execution.runRequest("request-id")',
+ errorMessage:
+ "pm.execution.runRequest() is not supported in Hoppscotch (Collection Runner feature)",
+ },
+ {
+ api: "pm.sendRequest()",
+ script: 'pm.sendRequest("https://example.com", () => {})',
+ errorMessage: "pm.sendRequest() is not yet implemented in Hoppscotch",
+ },
+ {
+ api: "pm.visualizer.set()",
+ script: 'pm.visualizer.set("Test
")',
+ errorMessage:
+ "pm.visualizer.set() is not supported in Hoppscotch (Postman Visualizer feature)",
+ },
+ {
+ api: "pm.visualizer.clear()",
+ script: "pm.visualizer.clear()",
+ errorMessage:
+ "pm.visualizer.clear() is not supported in Hoppscotch (Postman Visualizer feature)",
+ },
+ {
+ api: "pm.require()",
+ script: 'pm.require("@team/package")',
+ errorMessage:
+ "pm.require('@team/package') is not supported in Hoppscotch (Package Library feature)",
+ },
+]
describe("pm namespace - unsupported features", () => {
- test("pm.info.iteration throws error", () => {
- return expect(
- runTest(
- `
- try {
- const iteration = pm.info.iteration
- pm.test("Should not reach here", () => {
- pm.expect(true).toBe(false)
- })
- } catch (error) {
- pm.test("Throws correct error", () => {
- pm.expect(error.message).toInclude("pm.info.iteration is not supported")
- })
- }
- `,
- {
+ // Test unsupported APIs in both pre-request and test scripts
+ test.each(unsupportedApis)(
+ "$api throws error in pre-request script",
+ ({ script, errorMessage }) => {
+ return expect(
+ runPreRequest(script, {
global: [],
selected: [],
- }
- )()
- ).resolves.toEqualRight([
- expect.objectContaining({
- children: [
- expect.objectContaining({
- descriptor: "Throws correct error",
- expectResults: [{ status: "pass", message: expect.any(String) }],
- }),
- ],
- }),
- ])
- })
+ })()
+ ).resolves.toEqualLeft(`Script execution failed: Error: ${errorMessage}`)
+ }
+ )
- test("pm.info.iterationCount throws error", () => {
- return expect(
- runTest(
- `
- try {
- const iterationCount = pm.info.iterationCount
- pm.test("Should not reach here", () => {
- pm.expect(true).toBe(false)
- })
- } catch (error) {
- pm.test("Throws correct error", () => {
- pm.expect(error.message).toInclude("pm.info.iterationCount is not supported")
- })
- }
- `,
- {
+ test.each(unsupportedApis)(
+ "$api throws error in test script",
+ ({ script, errorMessage }) => {
+ return expect(
+ runTest(script, {
global: [],
selected: [],
- }
- )()
- ).resolves.toEqualRight([
- expect.objectContaining({
- children: [
- expect.objectContaining({
- descriptor: "Throws correct error",
- expectResults: [{ status: "pass", message: expect.any(String) }],
- }),
- ],
- }),
- ])
- })
-
- test("pm.collectionVariables.get() throws error", () => {
- return expect(
- runTest(
- `
- try {
- pm.collectionVariables.get("test")
- pm.test("Should not reach here", () => {
- pm.expect(true).toBe(false)
- })
- } catch (error) {
- pm.test("Throws correct error", () => {
- pm.expect(error.message).toInclude("pm.collectionVariables.get() is not supported")
- })
- }
- `,
- {
- global: [],
- selected: [],
- }
- )()
- ).resolves.toEqualRight([
- expect.objectContaining({
- children: [
- expect.objectContaining({
- descriptor: "Throws correct error",
- expectResults: [{ status: "pass", message: expect.any(String) }],
- }),
- ],
- }),
- ])
- })
-
- test("pm.vault.get() throws error", () => {
- return expect(
- runTest(
- `
- try {
- pm.vault.get("test")
- pm.test("Should not reach here", () => {
- pm.expect(true).toBe(false)
- })
- } catch (error) {
- pm.test("Throws correct error", () => {
- pm.expect(error.message).toInclude("pm.vault.get() is not supported")
- })
- }
- `,
- {
- global: [],
- selected: [],
- }
- )()
- ).resolves.toEqualRight([
- expect.objectContaining({
- children: [
- expect.objectContaining({
- descriptor: "Throws correct error",
- expectResults: [{ status: "pass", message: expect.any(String) }],
- }),
- ],
- }),
- ])
- })
-
- test("pm.iterationData.get() throws error", () => {
- return expect(
- runTest(
- `
- try {
- pm.iterationData.get("test")
- pm.test("Should not reach here", () => {
- pm.expect(true).toBe(false)
- })
- } catch (error) {
- pm.test("Throws correct error", () => {
- pm.expect(error.message).toInclude("pm.iterationData.get() is not supported")
- })
- }
- `,
- {
- global: [],
- selected: [],
- }
- )()
- ).resolves.toEqualRight([
- expect.objectContaining({
- children: [
- expect.objectContaining({
- descriptor: "Throws correct error",
- expectResults: [{ status: "pass", message: expect.any(String) }],
- }),
- ],
- }),
- ])
- })
-
- test("pm.execution.setNextRequest() throws error", () => {
- return expect(
- runTest(
- `
- try {
- pm.execution.setNextRequest("next-request")
- pm.test("Should not reach here", () => {
- pm.expect(true).toBe(false)
- })
- } catch (error) {
- pm.test("Throws correct error", () => {
- pm.expect(error.message).toInclude("pm.execution.setNextRequest() is not supported")
- })
- }
- `,
- {
- global: [],
- selected: [],
- }
- )()
- ).resolves.toEqualRight([
- expect.objectContaining({
- children: [
- expect.objectContaining({
- descriptor: "Throws correct error",
- expectResults: [{ status: "pass", message: expect.any(String) }],
- }),
- ],
- }),
- ])
- })
-
- test("pm.sendRequest() throws error", () => {
- return expect(
- runTest(
- `
- try {
- pm.sendRequest("https://example.com", () => {})
- pm.test("Should not reach here", () => {
- pm.expect(true).toBe(false)
- })
- } catch (error) {
- pm.test("Throws correct error", () => {
- pm.expect(error.message).toInclude("pm.sendRequest() is not yet implemented")
- })
- }
- `,
- {
- global: [],
- selected: [],
- }
- )()
- ).resolves.toEqualRight([
- expect.objectContaining({
- children: [
- expect.objectContaining({
- descriptor: "Throws correct error",
- expectResults: [{ status: "pass", message: expect.any(String) }],
- }),
- ],
- }),
- ])
- })
-
- test("pm.visualizer.set() throws error", () => {
- return expect(
- runTest(
- `
- try {
- pm.visualizer.set("Test
")
- pm.test("Should not reach here", () => {
- pm.expect(true).toBe(false)
- })
- } catch (error) {
- pm.test("Throws correct error", () => {
- pm.expect(error.message).toInclude("pm.visualizer.set() is not supported")
- })
- }
- `,
- {
- global: [],
- selected: [],
- }
- )()
- ).resolves.toEqualRight([
- expect.objectContaining({
- children: [
- expect.objectContaining({
- descriptor: "Throws correct error",
- expectResults: [{ status: "pass", message: expect.any(String) }],
- }),
- ],
- }),
- ])
- })
-
- test("pm.visualizer.clear() throws error", () => {
- return expect(
- runTest(
- `
- try {
- pm.visualizer.clear()
- pm.test("Should not reach here", () => {
- pm.expect(true).toBe(false)
- })
- } catch (error) {
- pm.test("Throws correct error", () => {
- pm.expect(error.message).toInclude("pm.visualizer.clear() is not supported")
- })
- }
- `,
- {
- global: [],
- selected: [],
- }
- )()
- ).resolves.toEqualRight([
- expect.objectContaining({
- children: [
- expect.objectContaining({
- descriptor: "Throws correct error",
- expectResults: [{ status: "pass", message: expect.any(String) }],
- }),
- ],
- }),
- ])
- })
+ })()
+ ).resolves.toEqualLeft(`Script execution failed: Error: ${errorMessage}`)
+ }
+ )
})
diff --git a/packages/hoppscotch-js-sandbox/src/bootstrap-code/post-request.js b/packages/hoppscotch-js-sandbox/src/bootstrap-code/post-request.js
index 809047e0..b3408971 100644
--- a/packages/hoppscotch-js-sandbox/src/bootstrap-code/post-request.js
+++ b/packages/hoppscotch-js-sandbox/src/bootstrap-code/post-request.js
@@ -3751,37 +3751,37 @@
collectionVariables: {
get: () => {
throw new Error(
- "pm.collectionVariables.get() is not supported in Hoppscotch (Workspace feature)"
+ "pm.collectionVariables.get() is not supported in Hoppscotch (use environment or request variables instead)"
)
},
set: () => {
throw new Error(
- "pm.collectionVariables.set() is not supported in Hoppscotch (Workspace feature)"
+ "pm.collectionVariables.set() is not supported in Hoppscotch (use environment or request variables instead)"
)
},
unset: () => {
throw new Error(
- "pm.collectionVariables.unset() is not supported in Hoppscotch (Workspace feature)"
+ "pm.collectionVariables.unset() is not supported in Hoppscotch (use environment or request variables instead)"
)
},
has: () => {
throw new Error(
- "pm.collectionVariables.has() is not supported in Hoppscotch (Workspace feature)"
+ "pm.collectionVariables.has() is not supported in Hoppscotch (use environment or request variables instead)"
)
},
clear: () => {
throw new Error(
- "pm.collectionVariables.clear() is not supported in Hoppscotch (Workspace feature)"
+ "pm.collectionVariables.clear() is not supported in Hoppscotch (use environment or request variables instead)"
)
},
toObject: () => {
throw new Error(
- "pm.collectionVariables.toObject() is not supported in Hoppscotch (Workspace feature)"
+ "pm.collectionVariables.toObject() is not supported in Hoppscotch (use environment or request variables instead)"
)
},
replaceIn: () => {
throw new Error(
- "pm.collectionVariables.replaceIn() is not supported in Hoppscotch (Workspace feature)"
+ "pm.collectionVariables.replaceIn() is not supported in Hoppscotch (use environment or request variables instead)"
)
},
},
diff --git a/packages/hoppscotch-js-sandbox/src/bootstrap-code/pre-request.js b/packages/hoppscotch-js-sandbox/src/bootstrap-code/pre-request.js
index 15f80311..adcee60b 100644
--- a/packages/hoppscotch-js-sandbox/src/bootstrap-code/pre-request.js
+++ b/packages/hoppscotch-js-sandbox/src/bootstrap-code/pre-request.js
@@ -1219,7 +1219,7 @@
},
// Unsupported APIs that throw errors
- sendRequest: () => {
+ sendRequest: (_request, _callback) => {
throw new Error("pm.sendRequest() is not yet implemented in Hoppscotch")
},
@@ -1255,6 +1255,11 @@
"pm.collectionVariables.toObject() is not supported in Hoppscotch (use environment or request variables instead)"
)
},
+ replaceIn: () => {
+ throw new Error(
+ "pm.collectionVariables.replaceIn() is not supported in Hoppscotch (use environment or request variables instead)"
+ )
+ },
},
// Postman Vault (unsupported)
@@ -1317,15 +1322,47 @@
"pm.iterationData.toObject() is not supported in Hoppscotch (Collection Runner feature)"
)
},
+ toJSON: () => {
+ throw new Error(
+ "pm.iterationData.toJSON() is not supported in Hoppscotch (Collection Runner feature)"
+ )
+ },
},
// Execution control (unsupported)
execution: {
+ location: (() => {
+ const location = ["Hoppscotch"]
+ Object.defineProperty(location, "current", {
+ value: "Hoppscotch",
+ writable: false,
+ enumerable: true,
+ })
+ Object.freeze(location)
+ return location
+ })(),
setNextRequest: () => {
throw new Error(
"pm.execution.setNextRequest() is not supported in Hoppscotch (Collection Runner feature)"
)
},
+ skipRequest: () => {
+ throw new Error(
+ "pm.execution.skipRequest() is not supported in Hoppscotch (Collection Runner feature)"
+ )
+ },
+ runRequest: () => {
+ throw new Error(
+ "pm.execution.runRequest() is not supported in Hoppscotch (Collection Runner feature)"
+ )
+ },
+ },
+
+ // Package imports (unsupported)
+ require: (packageName) => {
+ throw new Error(
+ `pm.require('${packageName}') is not supported in Hoppscotch (Package Library feature)`
+ )
},
}
}