Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要使用节点 js 脚本中的 k6 发送请求
我已经尝试过这个:
import http from "k6/http";
和这个:
var http = require('k6/http')
但没有成功
UPD
我想像这样使用k6:节点js脚本:
var http = require('k6/http'); var fs = require('fs'); http.get("http://test.loadimpact.com/");
您不能在 node.js 或除 k6 之外的任何其他地方使用k6/http或任何其他模块。k6/*这些模块不是用 JavaScript 编写的,它们是用 Go 编写的,并且是 k6 内部的——k6 二进制文件的一部分(即编译入)。它们只能从通过 k6 的 JavaScript 运行时运行的脚本访问,即goja,而不是node.js。
k6/http
k6/*