github-actions - GitHub Action Vitest CI 管道

标签 github-actions vite vitest

我想使用 GitHub Action 创建一个CI 管道,但我遇到了问题。该项目的前端是在Vue 3中开发的,并使用vitest来运行测试。它位于根目录中名为“WEB”的文件夹中。因此,我想在主分支中的每次提交时运行测试,但它返回此错误:

Error: .github#L1
each step must define a `uses` or `run` key

我使用了预先存在的“Node.js”模板,只是添加了“working-directory”属性来指定“WEB”文件夹。

这是我的“.yml”文件

name: Runs frontend tests

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [16.x]

    steps:
      - uses: actions/checkout@v3
      - name: Use Node.js ${{ matrix.node-version }}
        working-directory: ./WEB
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm'
      - name: Execute Unit tests
      - run: npm ci
      - run: npm run test

最佳答案

当您添加 - 时,它会在 steps 数组中添加一个元素:

你应该这样做:

- name: Execute Unit tests
  run: |
    npm ci
    npm run test

关于github-actions - GitHub Action Vitest CI 管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74499932/

相关文章:

来自 Github Actions 的 Terraform Init

typescript - 如何将 typescript 添加到 Vue 3 和 Vite 项目

javascript - Vue3-使用 Vitest toHaveBeenCalled() 方法

php - 为azure windows web应用程序terraform设置php版本时出错

npm - 从 Github 操作中检索 Github Registry npm 包

vite - 我的构建过程中出现了关于 globalThis.process.env.NODE_ENV 的语法错误

vue.js - 窗口未定义 Vite Vitesse

vuejs3 - Nuxt3无法在测试中导入组件

GitHub 操作工作流计划不适用于非默认分支