Github Actions中Angular单元测试通过后npm test挂起求助
Github Actions中Angular测试步骤卡住无法推进的问题
在Github Actions工作流中添加了运行Angular测试的步骤,使用ng test命令执行,测试本身成功通过,但工作流始终卡在该步骤,无法进入下一步。
已尝试的解决方法:
- 在步骤命令中添加
--watch=false参数,避免ng test监听文件变更 - 在
karma.conf.js中设置singleRun: true
以上方法均无效,也未找到其他可解决该问题的资源。
相关代码片段
工作流中测试步骤片段
- name: Run tests run: npm test -- --watch=false --browsers=ChromeHeadless
karma.conf.js文件片段
reporters : ['progress', 'kjhtml'], port : 9876, colors : true, logLevel : config.LOG_INFO, autoWatch : true, browsers : ['Chrome'], singleRun : true, restartOnFileChange: true,
完整工作流yaml文件
name: Build PUSH only on: push jobs: build: runs-on: ubuntu-latest env: SHA: ${{ github.sha }} REPO: ${{ github.repository }} BRANCH: ${{ github.ref_name }} CI: true steps: - name: Checkout the PR uses: actions/checkout@v3 - name: Set up Node uses: actions/setup-node@v3 with: node-version: 16 - name: Install Azure CLI run: curl -sL https://aka.md/InstallAzureCLIDec | sudo bash - name: Install Angular CLI run: npm install --location=global @angular/cli@14.0.0 - name: Install packages run: npm install - name: Build the UI run: ng build -c production - name: Run tests run: npm test -- --watch=false --browsers=ChromeHeadless
运行状态说明
工作流运行状态显示,进程一直卡在测试环节,未能执行后续的Post Set up Node步骤。
内容的提问来源于stack exchange,提问作者simon777
相关产品推荐
相关产品推荐

