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.

Config 'testTimeout' not working inside 'projects' config

See original GitHub issue

🐛 Bug Report

The configuration testTimeout (https://jestjs.io/docs/en/configuration#testtimeout-number) does not work in projects (https://jestjs.io/docs/en/configuration#projects-arraystring--projectconfig)

To Reproduce

Use this config and write a test taking more than 1 ms.

module.exports = {
  projects: [
    {
      testEnvironment: 'node',
      testTimeout: 1,
    },
  ],
};

Expected behavior

I expect each it(), beforeEach() etc. to time out after 1 ms.

Note that if you move the testTimeout: 1, outside of the projects array the config does kick in. I.e. this works:

module.exports = {
  testTimeout: 1,
  projects: [
    {
      testEnvironment: 'node',
    },
  ],
};

Original implementation: https://github.com/facebook/jest/issues/6216

Link to repl or repo (highly encouraged)

const { promisify } = require('util');

const sleep = promisify(setTimeout);

describe('suite A', () => {
  it('1', async () => {
    await sleep(2000);
    expect(true).toBeTruthy();
  });
});

envinfo

  System:
    OS: Linux 4.4 Ubuntu 16.04.5 LTS (Xenial Xerus)
    CPU: (4) x64 Intel(R) Xeon(R) Gold 6132 CPU @ 2.60GHz
  Binaries:
    Node: 12.13.0 - ~/.config/nvm/12.13.0/bin/node
    npm: 6.12.0 - ~/.config/nvm/12.13.0/bin/npm
  npmPackages:
    jest: 25.1.0 => 25.1.0

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
GeertWillecommented, Sep 29, 2020

I don’t think this is fixed… We encountered the same issue on version 26.4.2.

0reactions
jeremy-wcommented, Jul 26, 2021

see also https://github.com/facebook/jest/issues/9696, which suggests hoisting the testTimeout setting up a level out of the project config as a workaround (provided you’re OK with the same timeout across all test projects).

Read more comments on GitHub >

github_iconTop Results From Across the Web

testTimeout config not working in projects · Issue #9696 - GitHub
Use this config and write a test taking more than 1 ms. module.exports = { projects: [ { testEnvironment ...
Read more >
Configure jest timeout once for all tests - Stack Overflow
The issue I am facing is I am running a series of tests against an API that is very slow, 5-15 second response...
Read more >
Configuring Jest
The bail config option can be used here to have Jest stop running tests ... This will collect coverage information for all the...
Read more >
Testing Your Application - Quarkus
This allows you to run tests while having the application running in parallel. Changing the test port. You can configure the ports used...
Read more >
Test runner - Storybook
Test runner offers zero-config support for Storybook. ... your project, you should be able to migrate them into Storybook's test-runner without any issues....
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