【发布时间】:2016-08-20 08:47:39
【问题描述】:
我查看了 react-intl 的建议,但它没有为 enzyme 留下任何明确的文档。
这就是我一直在尝试编写测试的方式。
import {IntlProvider} from 'react-intl';
const intlProvider = new IntlProvider({locale: 'en'}, {});
const intl = intlProvider.getChildContext();
const customMessage = shallow(<CustomMessage />, { options: { context: intl } });
但我不断收到错误
不变违规:[React Intl] 找不到所需的
intl对象。需要存在于组件祖先中。
我查看了他们的仓库,他们似乎有 made it work 和 'react-addons-test-utils'。
我做错了吗?
【问题讨论】:
标签: unit-testing reactjs enzyme react-intl