[GH-ISSUE #2647] [feature]: console.log in the Pre-Script #873

Closed
opened 2026-03-16 17:30:32 +03:00 by kerem · 5 comments
Owner

Originally created by @darwinsubramaniam on GitHub (Sep 7, 2022).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/2647

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

console.log("HI")

added console.log into the pre-request script , was expecting it work as it is simple javascript but it returns error

  • ReferenceError: 'console' is not defined

Steps to reproduce

  1. Open https://hoppscotch.io/
  2. Open Pre-request Script Tab.
  3. Type in console.log("hi")
  4. Send request

Environment

Production

Version

Cloud

Originally created by @darwinsubramaniam on GitHub (Sep 7, 2022). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/2647 ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior `console.log("HI")` added console.log into the pre-request script , was expecting it work as it is simple javascript but it returns error - > ReferenceError: 'console' is not defined ### Steps to reproduce 1. Open https://hoppscotch.io/ 2. Open Pre-request Script Tab. 3. Type in console.log("hi") 4. Send request ### Environment Production ### Version Cloud
kerem 2026-03-16 17:30:32 +03:00
Author
Owner

@CHCoffman commented on GitHub (Sep 7, 2022):

I have been working on this but for the post-request test runner where the response body of the request (or whatever else) can be logged to the console. Ex: pw.log(pw.response.body) to see the response's body. My code in test-runner.ts is

        const logResponse = vm.newFunction("log", (input) => {
          const response = vm.dump(input)

          console.log(response)

          return { value: vm.undefined }
        })

        vm.setProp(pwHandle, "log", logResponse)
        logResponse.dispose()

pw-test.json:
"log" : "fn(value: ?)"

Looks like console.log from the test runner to browser is blocked via pure_funcs: ["console.log", "console.debug", "console.warn"], in nuxt.config.js.

When removing "console.log" from pure_funcs, you can now see it in the console. My question: is this important to keep or is this something that can be removed and the log function contributed as a feature?

<!-- gh-comment-id:1239461439 --> @CHCoffman commented on GitHub (Sep 7, 2022): I have been working on this but for the post-request test runner where the response body of the request (or whatever else) can be logged to the console. Ex: pw.log(pw.response.body) to see the response's body. My code in test-runner.ts is ``` const logResponse = vm.newFunction("log", (input) => { const response = vm.dump(input) console.log(response) return { value: vm.undefined } }) vm.setProp(pwHandle, "log", logResponse) logResponse.dispose() ``` pw-test.json: `"log" : "fn(value: ?)"` Looks like console.log from the test runner to browser is blocked via `pure_funcs: ["console.log", "console.debug", "console.warn"],` in nuxt.config.js. When removing "console.log" from pure_funcs, you can now see it in the console. My question: is this important to keep or is this something that can be removed and the log function contributed as a feature?
Author
Owner

@AndrewBastin commented on GitHub (Sep 7, 2022):

We are working on this actually and are working towards implementing this and the other features mentioned in this RFC (#2292). This will take some time, but we are making steady progress which can be tracked over here (#2389).

I do realize this blocks some more useful features (for example the console API introduction) behind the whole implementation. But we are hoping to complete the entire revamp in a couple of months and hopefully by max before the end of the year.

<!-- gh-comment-id:1239588538 --> @AndrewBastin commented on GitHub (Sep 7, 2022): We are working on this actually and are working towards implementing this and the other features mentioned in this RFC (#2292). This will take some time, but we are making steady progress which can be tracked over here (#2389). I do realize this blocks some more useful features (for example the `console` API introduction) behind the whole implementation. But we are hoping to complete the entire revamp in a couple of months and hopefully by max before the end of the year.
Author
Owner

@syamsoul commented on GitHub (Aug 11, 2023):

hi.. just wondering when this feature will be deployed?

<!-- gh-comment-id:1674180516 --> @syamsoul commented on GitHub (Aug 11, 2023): hi.. just wondering when this feature will be deployed?
Author
Owner

@ColdCerealAtWork commented on GitHub (Oct 11, 2023):

This is one of the features that's keeping me on Postman, I utilize the console heavily.

<!-- gh-comment-id:1758316207 --> @ColdCerealAtWork commented on GitHub (Oct 11, 2023): This is one of the features that's keeping me on Postman, I utilize the console heavily.
Author
Owner

@liyasthomas commented on GitHub (Jan 15, 2024):

Hoppscotch's pre-request scripts and post-request tests have complete compatibility with ECMAScript hence open the developer tools > console log in your browser (usually by pressing F12 or Ctrl/Cmd+Shift+I) to view logs.

Thanks for your patience and valuable feedback. This feature has been implemented in the latest release.

Closing this ticket as this feature is now available in the recent version. Please feel free to reach out if you have any other concerns.

<!-- gh-comment-id:1891765467 --> @liyasthomas commented on GitHub (Jan 15, 2024): Hoppscotch's pre-request scripts and post-request tests have complete compatibility with [ECMAScript](https://tc39.es/ecma262) hence open the developer tools > console log in your browser (usually by pressing `F12` or `Ctrl/Cmd`+`Shift`+`I`) to view logs. Thanks for your patience and valuable feedback. This feature has been implemented in the latest release. Closing this ticket as this feature is now available in the recent version. Please feel free to reach out if you have any other concerns.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#873
No description provided.