Reactjs 开玩笑;Typescript-jest.SpyOn类型错误
我正在尝试使用Reactjs 开玩笑;Typescript-jest.SpyOn类型错误,reactjs,typescript,jestjs,Reactjs,Typescript,Jestjs,我正在尝试使用jest.spyOn测试一个名为componentDidMount的方法。我不明白为什么方法onmountfaction返回Typescript错误: 类型为“OnMountFunction”的参数不能分配给的参数 类型 什么是nextap,你是在使用next.js还是什么?我同意@slideshowp2,你能给出一些关于nextap的上下文吗? class App extends NextApp<Props> { componentDidMount() {
jest.spyOn
测试一个名为componentDidMount
的方法。我不明白为什么方法onmountfaction
返回Typescript错误:
类型为“OnMountFunction”的参数不能分配给的参数
类型
什么是
nextap
,你是在使用next.js
还是什么?我同意@slideshowp2,你能给出一些关于nextap的上下文吗?
class App extends NextApp<Props> {
componentDidMount() {
this.onMountFuction('The Component Did Mount');
}
onMountFuction(msg: String) {
console.log(msg);
}
render() {
return (
<div></div>
);
}
}
describe('Test GTM Intergration', () => {
it('Should Init on ComponentDidMount', () => {
const Props = {
initialState: {},
};
const AppWrapper = new App(Props);
jest.spyOn(AppWrapper, 'onMountFuction'); // Argument of type '"onMountFuction"' is not assignable to parameter of type
});
});