Jest.js 在redwoodjs中设置测试

gcmastyq  于 11个月前  发布在  Jest
关注(0)|答案(1)|浏览(160)

我正在尝试在我的redwoodjs API中设置jest配置属性testTimeout。
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
我试探着:

  • 项目根目录中的./jest.config.js
// 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

  • 将其作为标志(如yarn rw test -- --testTimeout=10000)传递
  • 将其设置为场景函数的最后一个参数,例如-scenario('returns all bills', /* test body callback */, 10000)

在大多数情况下,它似乎被忽略或可能被覆盖,但在./api/jest.config.js中设置它的情况下,我确实收到了一条消息,说该属性未知。

● 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


我在最后一个例子中尝试了字符串和数字,以防万一,但没有爱。
你知道怎么设置玩笑超时吗

camsedfj

camsedfj1#

jest.setTimeout(10000)放入测试文件本身就可以工作。

相关问题