openlayers / openlayers

OpenLayers
https://openlayers.org
BSD 2-Clause "Simplified" License
11.45k stars 3.04k forks source link

All unit tests failing after importing ol in a Create-React-App app. #8239

Closed lduros closed 6 years ago

lduros commented 6 years ago

Thank you for your interest in making OpenLayers better!

To keep this project manageable for maintainers, we ask you to please check all boxes below before submitting an issue.

I have created a file and React component, which imports some of the OL classes at the top of the file using the import notation. Now whenever I run jest tests, using yarn test, I get the following error:

 ● renders correctly

    /Users/lduros/Development/quartet-ui/node_modules/ol/map.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import _ol_ from './index.js';
                                                                                                    ^^^^

    SyntaxError: Unexpected identifier

      at new Script (vm.js:74:7)
      at Object.<anonymous> (src/plugins/epcis/src/components/MapBody.js:21:12)

Has anyone encountered something like this?

Here is what I'm importing in my MapBody.js file, and everything works fine from the UI in the app, it's only when running tests, and those tests don't even interact directly with the MapBody.js file, it only happens during loading:

import React, {Component} from "react";
import "ol/ol.css";
import Map from "ol/map";
import View from "ol/view";
import Tile from "ol/layer/tile";
import OSM from "ol/source/osm";
import proj from "ol/proj";
import Point from "ol/geom/point";
import Feature from "ol/feature";
import Vector from "ol/source/vector";
import Style from "ol/style/style";
import Icon from "ol/style/icon";
import VectorLayer from "ol/layer/vector";

Many thanks,

lduros commented 6 years ago

Nevermind, I found another thread on this.

Thanks,

jpuskar commented 6 years ago

Feel free to post a link...

orpheus commented 5 years ago

yeah link to thread please

bryanSME commented 5 years ago

@lduros - this page is the top result on google with "import Feature from 'ol/Feature';" "jest". Where is this other link?