Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testTimeout config not working in projects #9696

Closed
thernstig opened this issue Mar 24, 2020 · 13 comments
Closed

testTimeout config not working in projects #9696

thernstig opened this issue Mar 24, 2020 · 13 comments

Comments

@thernstig
Copy link
Contributor

thernstig commented Mar 24, 2020

🐛 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: #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
@thernstig
Copy link
Contributor Author

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())?

@l-abels
Copy link

l-abels commented Jul 30, 2020

Any update on this? I've got one project containing long-running tests and one with shorter tests, so this functionality would be nice.

@crubier
Copy link

crubier commented Sep 18, 2020

I confirm, this is an oversight that should be easy to solve. In the meantime my configuration has to look like this:

module.exports = {
  testTimeout: 60000,
  projects: [
    { ... literally all other config options},
    { ... literally all other config options }
  ]
}

@thernstig
Copy link
Contributor Author

@crubier I am sure Jest would appreciate a PR if you can solve it 😃

@crubier
Copy link

crubier commented Sep 18, 2020

I have absolutely no knowledge of the codebase of jest, it will probably take me 2hours just to find the line of code to change. If someone want to give me a pointer I can do that.

@Niryo
Copy link

Niryo commented Dec 13, 2021

bump

@unandreshevia
Copy link

Unfortunately, the only solution I have found is adding setupFilesAfterEnv in the properties of the export, creating a file which is referenced there and putting jest.setTimeout=someNumber there.

Example:

module.exports = {
  setupFilesAfterEnv: ['./jest.setup.js'],
};

Example jest.setup.js file

jest.setTimeout(10000); // in milliseconds

@fellnerse
Copy link

fellnerse commented Aug 10, 2022

is there any progress on this?

@ErlanBelekov
Copy link

+1

@comp615
Copy link

comp615 commented 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

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Sep 30, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 30, 2023
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants