3

I have a question, after i update the openlayers from 5.3.1 to 6.3.1, when i run test, jest or mocha, both show the error "TypeError: URL.createObjectURL is not a function", what is the reason?

Mocha-Webpack:

TypeError: URL.createObjectURL is not a function
    at eval (webpack:///./node_modules/ol/worker/webgl.js?:7:15)

Jest:

FAIL test/map.test.js ● Test suite failed to run

TypeError: URL.createObjectURL is not a function

> 1 | import {Vector as VectorLayer} from "ol/layer.js";
    | ^
skyboyer
  • 22,209
  • 7
  • 57
  • 64
  • 1
    OpenLayers 6 uses WebGL for Heatmap layers and includes a plugin for webgl workers which uses URL.createObjectURL https://github.com/openlayers/openlayers/blob/master/tasks/serialize-workers.js#L46 To use a Heatmap layer you will need to enable URL in Jest https://stackoverflow.com/questions/52968969/jest-url-createobjecturl-is-not-a-function – Mike May 10 '20 at 13:03
  • Thanks for your answer! – user1018031 May 10 '20 at 21:54

0 Answers0