【发布时间】:2016-06-24 05:18:08
【问题描述】:
我想人们通常会同时使用 Flow 和 Jest(和 React),但 Flow 似乎并不了解 Jest(或 Jasmine)全局变量。当我将// @flow 添加到我的测试中时,我会收到这样的流错误:
src/__tests__/Thing-test.js:3
3: jest.unmock('../Thing')
^^^^ identifier `jest`. Could not resolve name
src/__tests__/Thing-test.js:7
7: describe('Thing', () => {
^^^^^^^^ identifier `describe`. Could not resolve name
src/__tests__/Thing-test.js:8
8: it('does stuff', () => {
^^ identifier `it`. Could not resolve name
我可以为 Jest/Jasmine 编写一个 Flow 接口,但这看起来很冗长,而且我必须遗漏一些东西。让 Flow 处理 node_modules/jest-cli 似乎没有帮助。
【问题讨论】:
-
您可以为 Jest 创建/安装声明文件。 manually 或使用 flow-typed:
flow-typed install jest。还可以查看配置了所有内容的存储库:node-flowtype-boilerplate