【发布时间】:2021-08-17 02:50:38
【问题描述】:
我正在使用 Node.js 在端口 8080 上运行客户端应用程序 (JS)。同时,我正在使用 Node.js 在端口 3030 上运行 Express Server。
集成测试是用 Jest 和 Selenium 编写的。为了测试应用程序,在我的本地机器上,我打开三个 Powershell 窗口并运行集成测试。它按预期工作并且测试用例通过。
Server Folder (new Terminal)
npm install
npm run start (Express.js)
Client Folder (new Terminal)
npm install
npm run start
Client Folder (new Terminal)
npm run tests
在 Azure Pipeline 中,我为图像“window-latest”创建了 YML,但它卡在了服务器启动处。
powershell:
display name: Server Start
npm install
npm run start
powershell:
display name: Client Start
npm install
npm run start | npm run test (Combined in package.json)
如果我在 Azure Pipeline 中删除 Server Start,则不需要服务器通过的测试用例。
两个项目都在一个存储库下。我在 Package.json 中使用 cd 命令在服务器位置安装和启动服务器。
start:server: "cd /server/dev/ && npm install && npm run start"
start:client: "npm install && npm run start"
test: "npm run start:server | npm run start:client | jest"
npm 运行测试,在我的本地机器上运行良好,服务器和客户端运行并且测试用例通过(单终端)。在 Azure Pipeline 上,我需要手动取消任务,因为 Azure 管道任务永远不会结束。分离脚本(Powershell)后,我注意到管道卡在 Express.js 服务器启动(通过在 YAML 中运行单个和组合的 npm 命令进行测试)。
问题:如何在启动 Client 之前在 Azure Pipeline 中启动 localhost Express Node.js 服务器?
【问题讨论】:
标签: node.js azure express azure-devops azure-pipelines