A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/facebook/jest/issues/13187 below:

reporter onRunComplete not triggered when jest runner crashed in watch mode · Issue #13187 · jestjs/jest · GitHub

Version

28.1.3

Steps to reproduce
  1. clone https://github.com/marr/jest-async-fail
    2. run yarn install
    3. create a simple reporter with onRunComplete and onRunStart methods if you are not using vscode-jest extension in vscode
    4. run jest command: with the custom reporter. For example, with the vscode-jest extension:
    yarn test --watchAll --no-coverage --reporters default --reporters "/your-vscode-extension-path/vscode-jest/out/reporter.js"

you should see something like this:


  ● Test suite failed to run

    Cannot find module 'vue-template-compiler'
    Require stack:
    - /jest-async-fail-main/node_modules/@vue/vue2-jest/lib/process.js
    - /jest-async-fail-main/node_modules/@vue/vue2-jest/lib/index.js
    - /jest-async-fail-main/node_modules/jest-util/build/requireOrImportModule.js
    - /jest-async-fail-main/node_modules/jest-util/build/index.js
    - /jest-async-fail-main/node_modules/jest-config/build/getCacheDirectory.js
    - /jest-async-fail-main/node_modules/jest-config/build/Defaults.js
    - /jest-async-fail-main/node_modules/jest-config/build/normalize.js
    - /jest-async-fail-main/node_modules/jest-config/build/index.js
    - /jest-async-fail-main/node_modules/jest-cli/build/init/index.js
    - /jest-async-fail-main/node_modules/jest-cli/build/cli/index.js
    - /jest-async-fail-main/node_modules/jest-cli/build/index.js
    - /jest-async-fail-main/node_modules/jest-cli/bin/jest.js
    - /jest-async-fail-main/node_modules/jest/bin/jest.js

      at Object.<anonymous> (node_modules/@vue/vue2-jest/lib/process.js:1:29)

onRunStart


Test Suites: 0 of 2 total
Tests:       0 total
Snapshots:   0 total

The onRunComplete, which should output "onRunComplete", is never invoked.

Expected behavior

the reporter should receive onRunComplete callback with at least testResult.testExecError populated.

Actual behavior

reporter onRunComplete was never called.

Additional context

We discovered this issue during the investigation of jest-community/vscode-jest#894. The culprit seems to be in TestScheduler where it catches runner exception and rethrow if it's in watch mode and not interrupted.

It didn't seem right as this resulted in reporters not knowing what is happening: it received the onRunStart but nothing else afterward. It is also inconsistent that other watch mode runs that are always reported with (onRunStart, onRunComplete) pair. It seems we could capture this error in TestResult.testExecError and report it via onRunComplete.

I could write a PR if you agree with the fix.

Environment
System:
    OS: macOS 12.5.1
    CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
  Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
  npmPackages:
    jest: ^28.1.3 => 28.1.3

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4