首页 > 解决方案 > 在 Windows 上通过 Github Actions 使用 Jest 时,日志中没有失败原因

问题描述

我正在尝试设置 Github Actions 以使用 Jest 运行我们的测试。问题是,当 Windows 上的测试失败时,我的操作日志中没有任何错误。

这是我的.github/workflows/CI.yml

name: CI
on: [push, pull_request]
jobs:
  Tests:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        node-version: [10]
        os: [ubuntu-latest, windows-latest, macOS-latest]
    steps:
    - run: git config --global core.autocrlf false
    - uses: actions/checkout@v1
    - uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: npm i -g yarn
    - name: yarn install and test
      run: |
        yarn config set ignore-engines true
        yarn
        yarn test --verbose=false
  Format:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-node@v1
    - run: npm i -g yarn
    - name: yarn install and format
      run: |
        yarn config set ignore-engines true
        yarn
        yarn format:prettier

yarn test运行jest tests。_

此操作在 Windows 上输出以下内容:

  yarn config set ignore-engines true
  yarn
  yarn test --verbose=false
  shell: C:\Program Files\PowerShell\6\pwsh.EXE -command ". '{0}'"
yarn config v1.22.0
success Set "ignore-engines" to "true".
Done in 0.06s.
yarn install v1.22.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.1.2: The platform "win32" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 43.23s.
yarn run v1.22.0
$ jest tests --verbose=false
FAIL tests/end-to-end.test.ts
##[error]Process completed with exit code 1.

我尝试过使用和不使用--verbose标志,但都输出:

FAIL tests/end-to-end.test.ts
##[error]Process completed with exit code 1.

仅此而已。甚至没有通过测试。我不知道这可能来自哪里。

此外,这仅在 Windows 上附加。在 Ubuntu 和 Mac 上,Jest 有正确的输出(成功的测试以及失败的原因)。

标签: node.jswindowsjestjsgithub-actions

解决方案


推荐阅读