我想用来react-test-renderer/shallow
测试我的react组件。
但是当我 import ShallowRenderer from 'react-test-renderer/shallow';
tsc
给我一个错误 'Module '"/Users/dulin/workspace/react-ts-webpack2/node_modules/@types/react-test-renderer/shallow/index"' has no default export.
那么,如何import
ShallowRenderer
与typescript
- 更新 -
最后,我将我的测试文件名从index.test.tsx
->更改index.test.jsx
为避免tsc
由definition
.
import * as React from 'react';
import * as TestUtils from 'react-dom/test-utils';
import * as ShallowRenderer from 'react-test-renderer/shallow';
import PanelHead from '../';
describe('PanelHead test suites', () => {
it('t-1', () => {
const renderer = new ShallowRenderer();
renderer.render(<PanelHead />)
const result = renderer.getRenderOutput();
expect(result.type).toBe('div');
});
});