You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 21, 2021. It is now read-only.
Hello. I want to add unit test for my inferno component. And I trapped by a error: TypeError: vNode.type is not a function.
Here is my component:
import{PureComponent,ComponentProps}from'@enow/enow-kernel';import{getStyle,getBody,getWrapper}from'./renderUtil';classTextElementextendsPureComponent<ComponentProps,any>{publicrender(){const{ model }=this.props;constslideId=this.context.currentSlideId;conststyle=getStyle({model});consttextChunk=getBody({model});constwrapper=getWrapper(model,style,textChunk);return(<divstyle={style}class="enow__text"id={`enow-text-${slideId}-${model.get('id')}`}>{wrapper||textChunk}{this.props.children}</div>);}}exportdefaultTextElement;
Here is my test case:
/** * 该用例存在问题,产生的snapshot不可用,若删去mock,报错:vNode.type is not a function */importTextElementfrom'../src/renderer';import{mount}from'enzyme';import{fromJS}from'@enow/enow-component-utils';jest.mock('@enow/enow-kernel');constmockModelStr=`{foo: 'bar'}`;constmockModelObj=fromJS(JSON.parse(mockModelStr));jest.mock('../src/textRun',()=>({}));describe('TextElement',()=>{it('TextElement should work well',()=>{constwrapper=mount(<TextElementmodel={mockModelObj}/>);expect(wrapper).toBeTruthy();expect(wrapper).toMatchSnapshot()});});
Hello. I want to add unit test for my inferno component. And I trapped by a error:
TypeError: vNode.type is not a function
.Here is my component:
Here is my test case:
@enow/enow-kernel
is a inner module, I mock it:This is error info that console output:
Could anyone please give me some advice? Thanks in advance~~~
The text was updated successfully, but these errors were encountered: