lightweight-charts
lightweight-charts copied to clipboard
Added test to check that the library importable in server-side context
Related issue #446.
In #484 @NekitCorp fixed importing the library in server-side context, but we need to be sure that it won't happen in the future. To avoid this, we need to add a test in CI to check that the library might be imported in nodejs context without any error (just imported, don't need to create chart or whatever).
Related issue #543
Is blocked by https://github.com/tradingview/fancy-canvas/issues/3
Any news on that one? I currently have a lot of tests failing which makes it unable to deploy my app as the build is not passing on CI. Is there a workaround or anything? I get the typical error that I've found in other issues here too:
import { bindToDevicePixelRatio } from 'fancy-canvas/coordinate-space';
^^^^^^
SyntaxError: Cannot use import statement outside a module
Any workarounds?
My workaround was to add the libraries to the transformIgnorePatterns
in the Jest config.
This doesn't solve the root cause, but sufficient as a workaround.
"transformIgnorePatterns": [
"node_modules/(?!(lightweight-charts|fancy-canvas)/)"
]
My workaround was to add the libraries to the
transformIgnorePatterns
in the Jest config.This doesn't solve the root cause, but sufficient as a workaround.
"transformIgnorePatterns": [ "node_modules/(?!(lightweight-charts|fancy-canvas)/)" ]
But only if you are not using an UNejected Create React App. In this case you could run them via CLI to bybass this issue, see https://github.com/facebook/create-react-app/issues/2537#issuecomment-390341713.
My workaround was to add the libraries to the
transformIgnorePatterns
in the Jest config.This doesn't solve the root cause, but sufficient as a workaround.
"transformIgnorePatterns": [ "node_modules/(?!(lightweight-charts|fancy-canvas)/)" ]
It not worked for me.
My workaround was to mock the module in setupTests.js
jest.mock('lightweight-charts', () => ({}));