Search code examples
jestjskonvajsts-jestts-nodekonva

Setup Konva with Jest


I'm trying to setup Jest with Konva, but getting this error:

TypeError: Cannot read property 'Stage' of undefined

  88 |     }
  89 |
> 90 |     const stage = new Konva.Stage({

I have imported Konva with import Konva from 'konva' in my TS file, and it works when I change that to import * as Konva from 'konva'

Is there a workaround to fix this module resolution on Jest?


Solution

  • I added these properties to my tsconfig.json and the issue resolved:

    {
     "allowSyntheticDefaultImports": true,
     "esModuleInterop": true
    }