set testTimeout in redwoodjs

22 Views Asked by At

I'm trying to set the jest config attribute testTimeout in my redwoodjs api.

https://redwoodjs.com/docs/testing#jest

https://jestjs.io/docs/cli#--testtimeoutnumber

https://jestjs.io/docs/configuration#testtimeout-number

https://jestjs.io/docs/api#testname-fn-timeout

I tried:

  • ./jest.config.js in the project root
// This the Redwood root jest config
// Each side, e.g. ./web/ and ./api/ has specific config that references this root
// More info at https://redwoodjs.com/docs/project-configuration-dev-test-build

module.exports = {
  rootDir: '.',
  projects: ['<rootDir>/{*,!(node_modules)/**/}/jest.config.js'],
  testTimeout: 10000,
}
  • ./api/jest.config.js
// More info at https://redwoodjs.com/docs/project-configuration-dev-test-build

const config = {
  rootDir: '../',
  preset: '@redwoodjs/testing/config/jest/api',
  testTimeout: 10000,
}

module.exports = config
  • passing it as a flag like yarn rw test -- --testTimeout=10000
  • setting it as the last argument to the scenario function E.g. - scenario('returns all bills', /* test body callback */, 10000)

In most cases it seems to be ignored or maybe overwritten, but in the case of setting it in ./api/jest.config.js I do get a message saying the attribute is unknown.

● Validation Warning:

  Unknown option "testTimeout" with value 10000 was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

I tried it both as a string and a number in this last case, just in case, but no love.

Any idea how to set the jest timeout?

1

There are 1 best solutions below

0
On

Putting jest.setTimeout(10000) in the test file itself works.