lightweight-charts icon indicating copy to clipboard operation
lightweight-charts copied to clipboard

Added test to check that the library importable in server-side context

Open timocov opened this issue 4 years ago • 7 comments

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).

timocov avatar Jun 18 '20 09:06 timocov

Related issue #543

timocov avatar Sep 22 '20 11:09 timocov

Is blocked by https://github.com/tradingview/fancy-canvas/issues/3

timocov avatar Nov 13 '20 09:11 timocov

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?

manuelbieh avatar Feb 23 '21 12:02 manuelbieh

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)/)"
    ]

tillkolter avatar Feb 23 '21 19:02 tillkolter

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.

RonnyBuergermeister avatar Jul 14 '21 13:07 RonnyBuergermeister

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.

raulvictorrosa avatar Nov 20 '21 18:11 raulvictorrosa

My workaround was to mock the module in setupTests.js

jest.mock('lightweight-charts', () => ({}));

cdaycmc avatar Jan 06 '22 01:01 cdaycmc