Skip to content

feat: Experimental Node JS integration to fully support any Javascript Package#28

Merged
deicon merged 3 commits intodevelopfrom
feat/alternative-javascript-runtimes
Oct 28, 2025
Merged

feat: Experimental Node JS integration to fully support any Javascript Package#28
deicon merged 3 commits intodevelopfrom
feat/alternative-javascript-runtimes

Conversation

@deicon
Copy link
Owner

@deicon deicon commented Oct 26, 2025

Description:
This PR introduces an experimental Node.js runtime for executing JavaScript within .http files, offering enhanced capabilities like npm package support and modern JavaScript features. It also adds corresponding documentation and an example to showcase the new functionality.

Motivation:
The current embedded Goja JavaScript engine lacks support for native npm packages and asynchronous helpers, limiting the flexibility and expressiveness of JavaScript code within .http scenarios. The experimental Node.js runtime addresses these limitations, allowing users to leverage a broader range of JavaScript features and libraries.

What was changed:

  • .gitignore: Added node_modules and results directories within the examples folder to the ignore list.
  • README.md: Updated documentation to include information on the --experimental-node-runtime flag, request helpers, await, and the experimental Node.js runtime.
  • cmd/httprunner/main.go:
    • Added the --experimental-node-runtime flag to enable the Node.js runtime.
    • Implemented logic to discover node_modules directories and add them to Node's module resolution paths.
    • Added logic to pass NODE_PATH environment to Node runtime for custom module layouts.
  • docs/specs/javascript-runtimes.md: Introduced a new document that outlines JavaScript execution for .http scenarios.
  • examples/external-node-runtime/: Added a new example folder demonstrating how to execute .http scenarios with the experimental Node.js runtime and consume dependencies installed from npm.
  • runner/runner.go:
    • Added useNodeRuntime and nodeRequirePaths fields to the Runner struct.
    • Implemented logic to enable the Node.js runtime and set the module resolution paths.
  • template/node_runtime.go: Added a new file containing the implementation of the Node.js runtime, including process management, message handling, and script execution.
  • template/node_worker.js: Added a new file containing the JavaScript code for the Node.js worker process, responsible for executing scripts and interacting with the httprunner process.
  • template/template.go:
    • Added RuntimeMode enum to select between goja and node runtime.
    • Implemented logic to execute scripts using the Node.js runtime.
    • Implemented logic to pass module resolution paths to the Node.js runtime.

Tests:
No new tests were written, and existing tests were not adapted to the new Node.js runtime. Warning: Comprehensive tests for the Node.js runtime are missing. Thorough testing is required to ensure the stability and reliability of the new feature.

@deicon deicon force-pushed the feat/alternative-javascript-runtimes branch from 42f322d to 7cef103 Compare October 28, 2025 06:44
@deicon deicon force-pushed the feat/alternative-javascript-runtimes branch from 7cef103 to 8467122 Compare October 28, 2025 06:45
@deicon deicon merged commit 954b1fb into develop Oct 28, 2025
12 checks passed
@deicon deicon deleted the feat/alternative-javascript-runtimes branch October 28, 2025 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant