简体   繁体   English

如何创建 GitHub Action 以使用 Yarn 运行 Jest 测试?

[英]How do I create a GitHub Action to run Jest tests with Yarn?

I use Yarn to run my Jest tests.我使用Yarn来运行我的Jest测试。

package.json

{
  "scripts": {
    "test": "jest"
  }
}
yarn test

I want to create a GitHub action to run my tests when I merge commits in GitHub.当我在 GitHub 中合并提交时,我想创建一个GitHub 操作来运行我的测试。 The Node Starter Workflow runs tests with NPM. Node Starter Workflow使用 NPM 运行测试。 But I want to run them with Yarn.但我想用 Yarn 运行它们。

How do I create an action to run my tests?如何创建一个操作来运行我的测试?

Use the Node Starter Workflow but replace the NPM portion with Yarn commands.使用Node Starter Workflow ,但将 NPM 部分替换为 Yarn 命令。 For example:例如:

name: Node CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x, 12.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: yarn install
    - run: yarn test

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 https 添加到纱线运行? - How do I add https to yarn run? 在所有测试都在玩笑中运行后,如何关闭 node.js 中的 pg-promise 连接? - how do I close pg-promise connection in node.js after all tests have run in jest? 如何在 github 操作中的特定文件夹中运行我的 CI 步骤 - How do I run my CI steps in a specific folder in github action 如何使用 Jest 等待文件中的测试完成以在另一个文件中开始测试? - How do I wait for the tests in a file to finish to start tests in another file using Jest? Github 操作上的 Jest 测试失败 - Jest Tests Failing on Github Actions 如何使用Node(express.js)后端和create-react-app作为前端运行Jest测试 - How to run Jest tests with Node (express.js) backend and create-react-app as frontend 如何卸载 Yarn - How Do I Uninstall Yarn 我可以像常规 js 文件一样运行 jest 测试吗? - Can I run jest tests as regular js files? JEST-当我在异步方法中运行“npm run jest”时,一些测试没有运行 - JEST- some of the tests are not running when I run "npm run jest" in async methods 如何修复:在 Jest 中运行测试时“TypeError:wsModule.Server 不是构造函数” - How do I fix: “TypeError: wsModule.Server is not a constructor” when running tests in Jest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM