TypeError: Cannot read properties of undefined (reading 'addEventListener') with StoryShots Storybook

914 Views Asked by At

I'm using Storyshots with storybook for snapshot testing. Referred to the documentation here: link1, link2

The complete error log

Followed all the steps here, but don't know why the error is coming :)

You can find the code here

I have also searched on the internet for possible solutions but didn't find any solution which helps.

Can someone please tell me how to fix this issue?

1

There are 1 best solutions below

0
On

I also had this error when I was using this jest.config.ts:

const config: Config = {
  preset: "ts-jest",
  testEnvironment: "node",
  verbose: true,
};

It was because of the wrong testEnvironment. Using jest-environment-jsdom (it should be installed separately) instead of node fixed the problem.