# Testing Cesium in Jest

**URL:** <https://community.cesium.com/t/testing-cesium-in-jest/20977>\
**Category:** CesiumJS\
**Created:** [October 27, 2022, 5:52pm UTC](https://community.cesium.com/t/testing-cesium-in-jest/20977 "2022-10-27T17:52:09Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![naftali123](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/naftali123/32/15710_2.png) [@naftali123](https://community.cesium.com/u/naftali123)\
**Post date:** [August 27, 2023, 12:22pm UTC](https://community.cesium.com/t/testing-cesium-in-jest/20977/10 "2023-08-27T12:22:07Z")

</div>

Hi Gabby,

I’ve attempted to implement the code you provided (for creating a CesiumJS Viewer with a WebGL stub) in my React (TypeScript + Resium) project. However, I’m still encountering the same error.  
Here is my code:  
"  
import getWebGLStub from “./getWebGLStub”;  
import { ContextOptions, Viewer, defaultValue } from “cesium”;

declare global {  
interface Window {  
webglStub?: boolean;  
}  
}

function createViewer(container: Element | string, options: Viewer.ConstructorOptions = {}) {  
options = defaultValue(options, {});  
options.contextOptions = defaultValue(options.contextOptions, {}) as ContextOptions;  
options.contextOptions.webgl = defaultValue(options.contextOptions.webgl, {});  
if (!!window.webglStub) {  
options.contextOptions.getWebGLStub = getWebGLStub;  
}

return new Viewer(container, options);  
}  
export default createViewer;  
"  
Could you please assist me in identifying what I might have missed or misconfigured?

Thank you.

---

_[View the full topic](https://community.cesium.com/t/testing-cesium-in-jest/20977)._
