1. A concise explanation of the problem you’re experiencing.
I am trying to spy on the Viewer constructor inside a Jasmine unit test but I do not know the proper way to do it, now that Cesium is written in ES6 modules.
Before version 1.63, Cesium was added to the window object and it was pretty easy to spy on it.
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
I used to spy on Viewer with the following code in pre-ES6 version
const viewer = new Cesium.Viewer(…);
it(‘should create a Cesium viewer’, () => {
const spy = spyOn(window[‘Cesium’], ‘Viewer’);
…
expect(spy.calls.any()).toBe(true);
});
``
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
4. The Cesium version you’re using, your operating system and browser.
Cesium 1.63
Windows 10 1903
Google Chrome 78.0.3904.70