可以使用PDFMake的测试组件
我想测试使用PDFMake的组件。当我将组件导入到测试文件中时,我会收到错误。
TypeError: Cannot read properties of undefined (reading 'pdfMake')
20 | import DirectionsBusIcon from "@mui/icons-material/DirectionsBus";
21 | import pdfMake from "pdfmake/build/pdfmake";
> 22 | import pdfFonts from "pdfmake/build/vfs_fonts";
| ^
23 | pdfMake.vfs = pdfFonts.pdfMake.vfs;
在PDFMake的页面上,他们提到了
“如果您使用的是汇总,并且在vfs_fonts.js错误上无法读取属性'pdfmake',则将其添加到汇总配置中:“
moduleContext: {
'./node_modules/pdfmake/build/vfs_fonts.js': 'window',
},
我如何为此配置开玩笑?
I want to test a component that uses pdfMake. When I import the component into my test file I get the error.
TypeError: Cannot read properties of undefined (reading 'pdfMake')
20 | import DirectionsBusIcon from "@mui/icons-material/DirectionsBus";
21 | import pdfMake from "pdfmake/build/pdfmake";
> 22 | import pdfFonts from "pdfmake/build/vfs_fonts";
| ^
23 | pdfMake.vfs = pdfFonts.pdfMake.vfs;
On the page for pdfMake they mention this
"If you are using rollup, and a Cannot read property ‘pdfMake’ of undefined at vfs_fonts.js error is thrown, add this to rollup config:"
moduleContext: {
'./node_modules/pdfmake/build/vfs_fonts.js': 'window',
},
How can I configure jest for that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论