question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🐛 Not generating outputFile provided in jest CLI

See original GitHub issue

🐛 Bug Report

Unable to genrate outputFile for jest.

Following is my configuration:

jest.config.js file:

module.exports = {
  collectCoverage: true,
  collectCoverageFrom: ['./src/**/*.js'],
  coverageReporters: ['json-summary', 'text', 'lcov'],
  globalSetup: './__tests__/global/test-setup-globals.js',
  globalTeardown: './__tests__/global/test-teardown-globals.js',
  roots: ['<rootDir>/__tests__'],
  testMatch: ['**/?(*.)+(spec|test).js'],
  testEnvironment: 'node',
  verbose: true,
}; 

package.json

{
  "name": "my-project",
  "version": "1.0.0",
  "main": "src/index.js",
  "scripts": {
    "start": "node src/index.js",
    "test": "jest --detectOpenHandles --json --outputFile=output.json"
  },
  "license": "ISC",
  "dependencies": {
  },
  "devDependencies": {
    "jest": "^26.6.3",
    "nock": "^13.0.5",
    "supertest": "^6.0.1"
  }
}

Running test with following command

npm test

To Reproduce

Steps to reproduce the behavior is make above mentioned configuration.

Also, tried many more combination of configuration. Anyone here facing same issue?

Expected behavior

Should generate output.json file

envinfo

  System:
    OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 12.19.1 - /usr/bin/node
    npm: 6.14.9 - /usr/bin/npm
  npmPackages:
    jest: ^26.6.3 => 26.6.3 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
connectdotzcommented, Jun 17, 2021

One of our issues (jest-community/vscode-jest#730) seems to bump into the same problem - the json file was not generated. After poking around for a bit, it seems related to the globalTeardown that forced the process to exit:

module.exports = function testTeardown() {
  process.exit();
};

If I disable the globalTeardown config or comment out the process.exit(), JSON file is generated as expected, but of course, the jest run did not close as that is what the process.exit() aim to resolve.

This might shed some light… maybe JSON is generated after the teardown? You can use the sample repo there to debug this issue.

0reactions
github-actions[bot]commented, Apr 10, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest CLI Options
Jest CLI Options. The jest command line runner has a number of useful options. You can run jest --help to view all available...
Read more >
Jest ---outputFile removes CLI coverage output - Stack Overflow
With --outputFile specified code coverage is still run and results are put in the coverage directory, but the CLI output doesn't include ...
Read more >
Jest CLI Options - GitHub Pages
The jest command line runner has a number of useful options. You can run jest --help to view all available options. Many of...
Read more >
jest-html-reporter - npm
Jest test results processor for generating a summary in HTML. Latest version: 3.7.0, last published: 3 months ago.
Read more >
Jest CLI Options - w3resource
To view all the available options, you can run jest ?help. Most of the options that are shown below can also be used...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found