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.

testTimeout config not working in projects

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:13
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
thernstigcommented, Mar 24, 2020

Also, is there a reason why jest.setTimeout() works for both test() and beforeAll() (all before/after hooks) whereas testTimeout does not (it only affects test())?

0reactions
comp615commented, Sep 30, 2022

Coming from jasmine runner, this seems like a gap in being able to use testTimeout as a replacement for jasmine.DEFAULT_TIMEOUT_INTERVAL

Read more comments on GitHub >

github_iconTop Results From Across the Web

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
When the projects configuration is provided with an array of paths or glob patterns, Jest will run tests in all of the specified...
Read more >
Configure unit tests by using a .runsettings file - Microsoft Learn
runsettings file in your solution and select one as the active test settings file as needed. Specify a run settings file in the...
Read more >
Test runner | Detox
There are many third-party solutions for running tests, so we're happy to not ... The integration with a test runner is a matter...
Read more >
Configuring Vitest
To configure vitest itself, add test property in your Vite config. ... Vitest uses workers not only for running tests in parallel, ...
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