highcharts / highcharts/highcharts-react-native
error thrown within Jest unit test
- Dominant language
- JavaScript
- Stars
- 105
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
I have a Jest unit test throwing an error when testing the creation of a bar chart. The call stack is as follows:
```
console.error
Failed to fetch scripts or layout. Cannot read property 'includes' of undefined
at CustomConsole.Object..console.error (../../node_modules/react-native/Libraries/LogBox/LogBox.js:33:14)
at registerError (../../node_modules/react-native/Libraries/YellowBox/YellowBox.js:169:7)
at errorImpl (../../node_modules/react-native/Libraries/YellowBox/YellowBox.js:84:22)
at CustomConsole.error (../../node_modules/react-native/Libraries/YellowBox/YellowBox.js:63:14)
at _callee$ (../../node_modules/@highcharts/highcharts-react-native/src/HighchartsReactNative.js:47:21)
at tryCatch (../../node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (../../node_modules/regenerator-runtime/runtime.js:293:22)
```
I have traced it in the HighchartsReactNative.js file to setHcAssets(), calling this.setLayout(), calling this.getAssetAsString() and the following code:
```
const downloadedModules = await FileSystem.readDirectoryAsync(FileSystem.cacheDirectory)
let fileName = 'ExponentAsset-' + asset.hash + '.' + asset.type
if (!downloadedModules.includes(fileName)) {
await asset.downloadAsync()
}
```
Seems like FileSystem react-native-unimodules is mocked, and has no cacheDirectory?
I tried the following
```
if (downloadedModules && !downloadedModules.includes(fileName)) {
```
But am now getting:
```
console.error
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in HighchartsReactNative (created by BarHighcharts)
```
For the unit test, I'm using @testing-library/react-native.
Anyway, I thought you should know. If this is an error on my part, please advise.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.