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

Jest: Ignore ol library #108

Merged
merged 1 commit into from
Oct 24, 2022
Merged

Jest: Ignore ol library #108

merged 1 commit into from
Oct 24, 2022

Conversation

andresmgot
Copy link
Contributor

What this PR does / why we need it:

The package @grafana/data 9.2.1, includes the "open layers" ol library. This fails to be imported by jest:

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
...
    Details:

    <plugin_path>/node_modules/ol/format/WKT.js:19
    import Feature from '../Feature.js';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
      at Object.<anonymous> (node_modules/@grafana/ui/dist/index.js:66:11)

To avoid this, Grafana main repo ignores the package:

https://github.com/grafana/grafana/blob/5361efc225e7d4b06322b0b9b2005102aa786a26/jest.config.js#L12-L14

So I am copying the same approach here.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@CLAassistant
Copy link

CLAassistant commented Oct 24, 2022

CLA assistant check
All committers have signed the CLA.

@academo academo requested a review from jackw October 24, 2022 11:10
Copy link
Collaborator

@jackw jackw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @andresmgot ! 🚀

I think as more packages transition away from supplying a cjs build we'll probably need to re-evaluate doing this with a regex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-plugin related to the create-plugin tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants