类型错误:无法读取未定义的属性“获取”
at node_modules/whatwg-fetch/fetch.js:4:8 at Object.<anonymous> (node_modules/whatwg-fetch/fetch.js:466:3) at Object.<anonymous> (node_modules/jest-expo/src/setup.js:97:348)
使用 jest-expo 运行测试时出错。如果有人有解决方案,请分享。
类型错误:无法读取未定义的属性“获取”
at node_modules/whatwg-fetch/fetch.js:4:8 at Object.<anonymous> (node_modules/whatwg-fetch/fetch.js:466:3) at Object.<anonymous> (node_modules/jest-expo/src/setup.js:97:348)
使用 jest-expo 运行测试时出错。如果有人有解决方案,请分享。
显然这是一个没有代码片段的猜测,但看看当时的fetch.js样子,我们无法读取undefined其fetch属性的值是变量self(参见第 1 行),它旨在设置为this上下文(参见第466)。
因此,似乎fetch.js是期待在一个环境中运行this是指window,但是jest-expo,作为一个测试工具,在其他一些环境中运行它,可能是在严格的模式下this是undefined。