提问人:Jagannath 提问时间:8/1/2023 最后编辑:JonasJagannath 更新时间:9/6/2023 访问量:77
类型错误:$(...)。telerik_ReportViewer不是一个函数 在我的 React Typescript 应用程序中使用 Jest 测试
TypeError: $(...).telerik_ReportViewer is not a function Using Jest test in my React Typescript Application
问:
● ReportViewer › 渲染时不会崩溃
TypeError: $(...).telerik_ReportViewer is not a function
27 | // Initialize the Telerik Report Viewer with the props
28 | if (this.reportViewerRef) {
> 29 | ($(this.reportViewerRef) as any).telerik_ReportViewer({
| ^
30 | serviceUrl: 'http://localhost/ReportWebAPI/api/reports/',
31 | reportSource: reportSource,
32 | scale: scale,
at ReportViewer.telerik_ReportViewer [as componentDidMount] (src/components/Reporting/Reportviewer/ReportViewerComponent.tsx:29:40)
at commitLayoutEffectOnFiber (node_modules/react-dom/cjs/react-dom.development.js:23310:28)
at commitLayoutMountEffects_complete (node_modules/react-dom/cjs/react-dom.development.js:24688:9)
at commitLayoutEffects_begin (node_modules/react-dom/cjs/react-dom.development.js:24674:7)
at commitLayoutEffects (node_modules/react-dom/cjs/react-dom.development.js:24612:3)
at commitRootImpl (node_modules/react-dom/cjs/react-dom.development.js:26823:5)
at commitRoot (node_modules/react-dom/cjs/react-dom.development.js:26682:5)
at finishConcurrentRender (node_modules/react-dom/cjs/react-dom.development.js:25981:9)
at performConcurrentWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:25809:7)
at flushActQueue (node_modules/react/cjs/react.development.js:2667:24)
at act (node_modules/react/cjs/react.development.js:2582:11)
at node_modules/@testing-library/react/dist/act-compat.js:46:25
at renderRoot (node_modules/@testing-library/react/dist/pure.js:161:26)
at render (node_modules/@testing-library/react/dist/pure.js:247:10)
at Object.<anonymous> (src/components/Reporting/Reportviewer/ReportViewerComponent.test.tsx:32:11)
尝试使用 Jest 测试我的 ReportViewer.TSX 组件,代码如下,但获得上述错误任何相同的线索
// Initialize the Telerik Report Viewer with the props
if (this.reportViewerRef) {
($(this.reportViewerRef) as any).telerik_ReportViewer({
serviceUrl: 'http://localhost/ReportWebAPI/api/reports/',
reportSource: reportSource,
scale: scale,
viewMode: viewMode,
printMode: printMode,
sendEmail: sendEmail,
});
}
答: 暂无答案
评论