Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing integration tests using jest framework #994

Closed
multidila opened this issue Mar 30, 2020 · 1 comment
Closed

Writing integration tests using jest framework #994

multidila opened this issue Mar 30, 2020 · 1 comment

Comments

@multidila
Copy link

Support Question

Perhaps such a question has already been asked, but, unfortunately, I could not find it.
In general, I need help with the following:
We are developing in a monorepe on Angular and use your library @finos/perspective. We connected it through npm, but when writing tests, we encountered a problem that the perspective instance is not visible during the test pass, that is, it is undefined, the same problem was when starting the application. Then we connected the perspective-webpack-plugin package, created webpack.config and everything worked in the browser, but the problem remained in the tests.
Tell me, please, do not know what could be the problem or which way to look? (there was a hypothesis that we need to add the same plugin in jest.config, but I don’t know how yet)

@texodus
Copy link
Member

texodus commented Apr 2, 2020

Thanks for the report!

As of 0.4.0, @finos/perspective-webpack-plugin is optional. Without it, you will just get an "inline" version of perspective, with the WebAssembly payload base64 encoded as a string embedded Javascript, which is slow to load but otherwise identical to the plugin-enabled version.

.. perspective instance is not visible ..

.. leads me to believe you are including the package's umd/perspective.js script directly and relying on its global namespace symbol to call Perspective's API. If this is the case, use a module import instead, which will resolve correctly in Node/Jest and the browser:

import perspective from "@finos/perspective"

Please take a look at the webpack example github project, which imports perspective correctly here.

I suspect for Jest specifically, this may be a struggle - Perspective's node.js and browser APIs are different, for starters, and the latter uses a laundry list of browser features that JSDom/Jest have nebulous support for (like Web Workers, Blob, ArrayBuffer, ..). You will get dramatically better results either mocking @finos/perspective-* modules, or using Puppeteer.

@texodus texodus closed this as completed Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants