【发布时间】:2020-12-15 14:27:11
【问题描述】:
我一直在使用 Expo CLI 在 React Native 中工作,最近开始面临我的单元测试由于一个常见原因而失败的问题。堆栈跟踪如下
Cannot read property 'toString' of undefined
at Converter.toBase64 (node_modules/convert-source-map/index.js:61:46)
at Converter.toComment (node_modules/convert-source-map/index.js:65:21)
at generateCode (node_modules/@babel/core/lib/transformation/file/generate.js:78:76)
at run (node_modules/@babel/core/lib/transformation/index.js:55:33)
at run.next (<anonymous>)
at transform (node_modules/@babel/core/lib/transform.js:27:41)
at transform.next (<anonymous>)
at evaluateSync (node_modules/gensync/index.js:244:28)
at sync (node_modules/gensync/index.js:84:14)
我的节点版本是 node:12.18.4。我想知道是什么导致了这些错误,因为一切正常。在我的本地系统上,它们运行良好,但偶尔会出现 CI 过程往往会导致它们随机失败,这会影响整体代码覆盖率。
我尝试运行的单元测试非常简单,如下所示
it('Renders Strings as expected', () => {
expect(received).toStrictEqual(expected)
})
【问题讨论】:
标签: react-native jestjs expo babeljs babel-jest