演员Js
ActorJs是您在浏览器中运行的端到端测试工具.
触发器、模拟器和拦截器.
ActorJs模拟了环绕测试下系统的所有进程和服务,使您能够非常高效地孤立测试下系统,无论测试下系统需要使用多少个周边系统或协议. 您创建使用堆栈进行通信的演员( 非常小的模拟器) .
先决条件
安装演员Js
npm install @actorjs/actorjs
更新演员Js
npm update
构建演员Js 服务器
aj release
如果您修改了文件, 但 ActorJs 尚未启动, 或者您从本地重存中提取更新, 您必须再次使用 aj 发行量。否则,只需使用 联合国 开始演员J.
Linux 麦克( Mac): 使用命令 联合国,则需要一种别名 演员.sh 文件在安装文件夹中。 在安装期间,将别名添加到 .bashrc (英语) (Linux和Mac)和 (英语) .zshrc (英语) (马来文). 如果使用另一个外壳,则需要自己添加外号. 第一次安装 ActorJs 时, 您需要重新启动终端或 来源 包含别名的文件,例如:
source ~/.bashrc
启动演员Js客户端
用url打开浏览器 http://localhost: 9005
文档
在 ActorJs 工具中进一步阅读
ActorJs的文档可以在工具中找到. 要访问它,请在工具运行时单击以下链接.
示例代码
HTTP - 服务器
*run() {
this.httpConnection.send(new HttpMsgGetRequest(this.requistUri));
const response = this.httpConnection.receive();
VERIFY_VALUE(HttpApi.StatusCode.OK, response.statusCode, ' HTTP response line status code:');
VERIFY_CONTENT_OPTIONAL('content-name', response.getHeaderNumber(HttpApi.Header.CONTENT_LENGTH), response.getBody());
}
Websocket - 客户端
*run() {
this.httpConnection.send(new HttpGetUpgradeRequest(this.requistUri, this.wsProtocol));
const response = this.httpConnection.receive();
this.websocketConnection = this.switchProtocol('websocket', this.httpConnection);
this.websocketConnection.send(new WebsocketStackApi.TextFrame(this.wsText, this.wsMask));
this.websocketConnection.send(new WebsocketStackApi.CloseFrame());
}
Puppeteer - 客户端
*run() {
const page = this.puppeteerConnection.page;
yield page.click('.w-button');
}
套接字 - 服务器
*run() {
this.socketConnection.accept();
const request = this.socketConnection.receiveLine();
VERIFY_VALUE('Hello World!', request)
}