问题描述
在测试我的页面时,从依赖项中抛出错误。该错误并不严重,不会干扰我的应用程序。但是当使用 puppeteer 进行测试时,出现这个错误,他只是关闭了被测试的页面。我如何防止这种情况继续测试而忽略此错误?
Error: TypeError: Cannot set property 'paddingLeft' of undefined
at FrozenColumns.layoutRow (webpack-internal:///./node_modules/react-tabulator/node_modules/tabulator-tables/dist/js/tabulator.es2015.js:16595:26)
at Row.initialize (webpack-internal:///./node_modules/react-tabulator/node_modules/tabulator-tables/dist/js/tabulator.es2015.js:5313:37)
at Row.reinitialize (webpack-internal:///./node_modules/react-tabulator/node_modules/tabulator-tables/dist/js/tabulator.es2015.js:5376:8)
at eval (webpack-internal:///./node_modules/react-tabulator/node_modules/tabulator-tables/dist/js/tabulator.es2015.js:4415:7)
at Array.forEach (<anonymous>)
at RowManager.reinitialize (webpack-internal:///./node_modules/react-tabulator/node_modules/tabulator-tables/dist/js/tabulator.es2015.js:4414:12)
at ColumnManager.redraw (webpack-internal:///./node_modules/react-tabulator/node_modules/tabulator-tables/dist/js/tabulator.es2015.js:1206:25)
at RowManager.refreshActiveData (webpack-internal:///./node_modules/react-tabulator/node_modules/tabulator-tables/dist/js/tabulator.es2015.js:3668:31)
at RowManager.sorterRefresh (webpack-internal:///./node_modules/react-tabulator/node_modules/tabulator-tables/dist/js/tabulator.es2015.js:3482:8)
at HTMLdivelement.eval (webpack-internal:///./node_modules/react-tabulator/node_modules/tabulator-tables/dist/js/tabulator.es2015.js:22644:27)
我的环境:
Puppeteer 版本:5.4.2
平台/操作系统版本:macOS 10.15.7
Node.js 版本:v12.16.1
解决方法
使用 jest-puppeteer 时,可以在 jest-puppeteer.config.js 中指定 exitOnPageError: false 参数。在这种情况下,如果页面出现错误,测试将无法完成。