Jest Progress bar and live stats not showing up when running in band

See original GitHub issue

๐Ÿ› Bug Report

When I run jest, I donโ€™t see the green progress bar or any of the live printout data in my terminal. The Test Suites, Tests, Snapshots, and Time stats are only printed out after all my tests are complete. Until tests are complete, the only indicator I see is:

RUNS path/to/tests

Thereโ€™s no way for me to tell whether the tests have stalled or are still running until the entire suite is complete.

I am running jest with puppeteer for end to end testing.

To Reproduce

  1. Clone the repo here: https://github.com/jeremygottfried/test-jest-cli
  2. Run yarn install
  3. Run yarn test (I set up jest global setup/teardown scripts to handle starting the server)

Test Code

import puppeteer from 'puppeteer';

describe('a basic react app that puppeteer can automate', () => {
  let browser;
  let page;

  beforeAll(async () => {
    browser = await puppeteer.launch({ slowMo: 250 });
    page = await browser.newPage();
  });

  afterAll(async () => {
    await browser.close();
  })

  it('opens the home page', async () => {
    await page.goto('http://localhost:3000');
    expect(await page.url()).toBe('http://localhost:3000/');
  })

  it('has app header', async () => {
    expect(await page.$('.App-header')).not.toBe(null);
  })

  it('has logo', async () => {
    expect(await page.$('img[src="/static/media/logo.5d5d9eef.svg"]')).not.toBe(null);
  })

  it('should have a Learn React link that opens a new page', async () => {
    await page.click('.App-link');
    expect(await page.url()).toBe('https://reactjs.org/')
  })
})

Global Setup Code

import spawnd from 'spawnd';
import cwd from 'cwd';
import http from 'http';

function serverReady() {
  return new Promise(function(resolve) {
    async function checkReady() {
      const req = http.get({
        hostname: 'localhost',
        port: 3000,
        path: '/',
      }, function (res) {
        if (res.statusCode === 200) {
          resolve();
        } else {
          return checkReady();
        }
      });
      req.on('error', function() {
        return checkReady();
      });
    }
    checkReady();
  });
}

export default async function setup() {
  console.log(`\nStarting up react server at port 3000...`);
  const server = spawnd('yarn', ['start'], { shell: true, cwd: cwd() });
  global.server = server;
  await serverReady();
  console.log('\nServer Ready');
}

Expected behavior

I expected my jest tests to show progress bar and live stats printouts like this:

jest expectation

Link to repl or repo (highly encouraged)

https://github.com/jeremygottfried/test-jest-cli

envinfo

  System:
    OS: macOS Mojave 10.14.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 13.6.0 - /usr/local/bin/node
    Yarn: 1.21.1 - /usr/local/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
  npmPackages:
    jest: ^24.9.0 => 24.9.0 
$ [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'
# => Interactive
shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'
# => Login shell

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:18

github_iconTop GitHub Comments

4reactions
jeremygottfriedcommented, Jan 21, 2020

Thanks @SimenB , that worked for showing the live stats and progress bar.

I agree it would be helpful to document what enables the live stats and progress bar. If the time estimate is long for a single test suite, maybe show it by default? My test suite takes around 4 minutes, which is quite a while to see RUNS path/to/my/test and nothing else.

1reaction
spinludcommented, Aug 23, 2022

Same here, I need --runInBand because the tests are very time sensitive and the parallel execution mess up things. Still unable to find a way to show the progress bar though (or any kind of progress output) ๐Ÿ™

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest is not showing green progress bar during tests
When I run my jest tests, the green progress bar and stats aren't printed to the console. It just prints RUNS path/to/my/test and...
Read more >
Jest CLI Options
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-progress-bar-reporter - npm
Start using jest-progress-bar-reporter in your project by running `npm i jest-progress-bar-reporter`. There are no other projects in the npmย ...
Read more >
Jest-progress-bar-reporter - Morioh
Welcome to Morioh! Let's write, share knowledge and earn GEEK. Sign up . Gordon Taylor.
Read more >
vscode-jest - Visual Studio Marketplace
Intermittent errors for (npm/yarn/node) command not found during test run or debugging; I don't see "Jest" in the bottom status bar ...
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