我正在尝试为我的打字稿React项目设置酶。但是出现以下错误:const m = moment('2019-03-13T16:51-07:00');
console.log(m.format('LT'));
。
我的测试用例非常简单,只需使用“ shallow”来测试HelloWorld组件。任何帮助将不胜感激!
TypeError: Cannot read property 'split' of undefined
我正在使用以下版本:
TypeError: Cannot read property 'split' of undefined
1 | const Enzyme = require('enzyme');
> 2 | const Adapter = require('enzyme-adapter-react-16');
| ^
3 |
4 | Enzyme.configure({ adapter: new Adapter() });
at new Range (node_modules/enzyme-adapter-utils/node_modules/semver/semver.js:800:20)
at intersects (node_modules/enzyme-adapter-utils/node_modules/semver/semver.js:1334:8)
at Object.<anonymous> (node_modules/enzyme-adapter-utils/build/wrapWithSimpleWrapper.js:37:39)
at Object.<anonymous> (node_modules/enzyme-adapter-utils/build/Utils.js:47:30)
at Object.<anonymous> (node_modules/enzyme-adapter-utils/build/index.js:4:18)
at Object.<anonymous> (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:47:27)
at Object.<anonymous> (node_modules/enzyme-adapter-react-16/build/index.js:4:18)
at Object.require (setupTests.js:2:18)
at Array.forEach (<anonymous>)
这是我的Jest配置:
jest.config.js:
react: "16.8.4"
react-dom: "16.8.4"
react-test-renderer: "16.8.4"
enzyme: "3.9.0"
enzyme-adapter-react-16: "1.11.0"